Please take a minute to review and accept our Terms of Use.
Welcome to the PLECS User Forum, where you can ask questions and receive answers from other members of the community.

Many technical questions regarding PLECS are answered on the Technical Solutions page of our website. Tutorial videos, specific application examples, and pre-recorded webinars are available on our YouTube page. Please follow us on LinkedIn for the latest Plexim news.

Automate looping through different submodules with Matlab / Blockset

0 votes
82 views
Hello everybody.

Trying to cycle through a number of different circuit configuration, I stumbled across this issue:

- Is it possible to change the configuration of a PLECS model submodule automatically using Matlab?

I have:

- A simulation model that takes variables for parameters and has different circuits, implemented as configurable submodules

- Matlab scripts to loop through one configuration for a parameter range

However, when I want to change the configuration of the submodule (switch to another circuit), I could not find an automatic way to do so (currently, I manually change the config in the drop down menu, see attached screenshot).

Any way to do so? Would be a great help for automation!
asked Jan 29 by JustinSane (12 points)

1 Answer

0 votes
Hello,

I recommend that you use a reference variable for the subsystem configuration selection parameter. You can then write a value to that variable from your script, where 1 equals the first configuration from left-to-right, 2 equals the second in order, etc.

Try this out and let me know if you are successful.

Regards,

Kris
answered Jan 29 by Kris Eberle (534 points)
Hey Kris.

Thanks for the quick reply. I already use this method to change values of circuit elements. However, I could not find a way to set a variable for the subsystem configuration. Is there any context menu I am missing?

Thanks and best regards!

Hello,

You will need to choose the 'reference' option for the Configuration parameter and overwrite this with a variable name that you can then write to from your script. See the simple example attached. You can include the following text in a .m file script or type it directly into the MATLAB command line to toggle between the two subsystem configurations: 

configuration = 1;

configuration = 2;

I also attached an example in PLECS Standalone for anyone else in the future that has this questions. Let me know if you have any issues.

Regards,
Kris

...