MATLAB Answers

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

2 views (last 30 days)
Martin Silge
Martin Silge on 2 Jun 2020
Answered: Joel Van Sickel on 5 Aug 2020
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

  0 Comments

Sign in to comment.

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

  0 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!