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

3 views (last 30 days)
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

Answers (1)

Joel Van Sickel
Joel Van Sickel on 5 Aug 2020
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

Categories

Find more on Composite Components in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!