Obtain PLECS parameter initial values from a .m file

What would be the easiest way to obtain the values for initializing the parameters from a .m File.

You can use the [b]run/b or [b]source/b Octave functions in the Model Initialization Commands.

What should be the file type of “file_name”.

Refer to the Octave help for these two functions.

The exact extension doesn’t matter, but the file search behavior will vary slightly depending on the extension. A very simple example is attached. Place the two files in the same folder.

load_param.plecs (2.64 KB)

param.m (7 Bytes)

Apparently, the presence of complex numbers in the .m file causes an immediate problem. Is there a straightforward solution for that?

PLECS doesn’t support complex numbers. What you can do is convert all complex values to their desired scalar representation (i.e. convert to real, imaginary, magnitude or angle). Then you can remove the complex number from the workspace by using the clear() function.

Could you provide an example? For your reference, I have attached the .m file I want to run for initialization.

param.m (1.38 KB)

You can see which numbers are complex by using the “whos” function. For example za, vu, vl, and vee in your script are all complex numbers. You would end the *.m file with:

clear('za','vu','vl','vee')