- You can try using the "Partitioning" local solver which is detailed in the Understanding How the Partitioning Solver Works documentation page. Please note that depending on your system and on the structure of your model, there is a possibility that this solver might not work for you.
- If this solver is not suitable for your model, you can try adding a "Simscape Component" block in which you change the model from variable resistor to piecewise linear as shown in the attached file "pwl_resistor.ssc" file. This workaround is based on assigning resistance values "R" in a piecewise manner based on a unitless input value (in this case called "u"). This allows the voltage value "v" being computed to no longer be directly dependent on the previous input value "R". Rather, it will be indirectly dependent on the new input value "u", all while having the resistance value "R" defined inside the script.
How can I implement variable resistor and variable inductor models for HDL code generation when using Simscape in MATLAB R2023b?
5 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2025-1-15
回答: MathWorks Support Team
2025-3-3
I am using MATLAB R2023b. My Simulink model includes variable resistors and variable inductors from the Simscape Electrical library. However, when I try to implement HDL code generation on my model, I get the following error:
Nonlinear Partitions are not supported for HDL Code Generation. Please refer to the Simscape Statistics viewer for more information on partitions within the System.
How can I implement variable resistors and variable inductors for HDL code generation?
采纳的回答
MathWorks Support Team
2025-4-5
As of MATLAB R2023b, variable resistors and variable inductors form the Simscape Electrical library are not compatible with HDL code generation. This persists in MATLAB R2024b. The reason behind this is the fact that they are "nonlinear" in the Simscape environment as explained below. Please note that this is different than mathematical nonlinearity.
In order to use variable resistors and variable inductors in a Simscape model for HDL code generation, you can try the following workarounds:
The attached example code includes only two values of "R", but additional values can be added. You can add the "SSC" code to a "Simscape Component" block according to the Simscape Component documentation page. Please ensure the "SSC" file is located in your MATLAB path when adding it to a "Simscape Component" block.
A similar workflow can be followed for variable inductors.
The documentation page for resolving issues for nonlinearities provides additional information on how to make the model compatible for HDL coder.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating Custom Components and Libraries 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!