How can I switch between thermal and standard block choice in Simscape block programmatically

2 次查看(过去 30 天)
Hi,
I want to be able to switch between different block choices for a given Simscape block from matlab code.
In detail, I want to switch between thermal and non-thermal (standard) variant in a resistor of the Electrical/Passive library.
I could not find a solution by searching the web, so I would very much appreciate any help.
Kind regards,
Martin

回答(1 个)

Joel Van Sickel
Joel Van Sickel 2020-8-5
Hello Martin,
unfortunately, there is no API to allow you to do this programmatically. While you can technically access this choices under mask options and change it with the parameter 'ComponentPath', it will not update the block choice in the simulink model. The only way to do this would be to have a custom library with a resistor with and without thermal ports. Then you could progrmatically remove a block and then add a block from this custom library. Just as you can't programmatically change the simscape variant, you can't control with one you add with add_block. The logic would be like this
This is non-trivial:
chose component to toggle betweent
save that components mask parameters
delete component
add other component from custom library
set new components values to the old components values
hook up wires same as old component (not sure if they will automatically connect even if you add the block exactly where the old block was)
Regards,
Joel

类别

Help CenterFile Exchange 中查找有关 Composite Components 的更多信息

产品


版本

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by