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

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.

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?

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.

script_from_script.zip (2.81 KB)

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.