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.

Is it possible in PLECS standalone to call a script from script?

0 votes
593 views
I'm using PLECS standalone and I want to use one script for setting parameters, and another script that calls first script and starts the simulation and does some other job. When I write the name of the first script in the second script I get an error like this:  Error in script 'set_parameters', line1: 'set_parameters' undefined.
asked Apr 9, 2021 by matija (21 points)
Are you using the inbuilt Simulation Scripts? You can call a .m file script from PLECS Standalone (Initialization Commands or Simulation Script) that contains your parameter definitions. Would that be suitable?

1 Answer

0 votes
 
Best answer
As Kris suggested you can call an *.m file from PLECS. The *.m files can be nested.  Attached is a simple example.

The issue is that PLECS can't seem to find the file you're referencing.  Are you calling "set_parameters" in the "set_parameters" script itself? Is it in a different folder or have a different name?

Personally, I think the run("model_name.m") syntax is a bit clearer since I know what's a script and whats a variable, and you can reference scripts in sub-folders.
answered Apr 9, 2021 by Bryan Lieblick (1,901 points)
selected Apr 13, 2021 by matija

One small note, the file-path syntax in the above model is OS dependent.  The file runs as is in Windows, but for OSX/Linux should be configured as:

run("folder/setR2.m")

Thank you for your answer. I actually meant something else. I have attached a screenshot for my question. I'm asking for calling script from script using Simulation Scripts window.  It show error that setParams is undefined. But now you showed me another way of calling scripts.

...