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.

Obtain PLECS parameter initial values from a .m file

0 votes
693 views
What would be the easiest way to obtain the values for initializing the parameters from a .m File.
asked Jul 4, 2022 by Anjana (19 points)

1 Answer

0 votes

You can use the run("file_name") or source("file_name") Octave functions in the Model Initialization Commands.

answered Jul 5, 2022 by Bryan Lieblick (1,841 points)

What should be the file type of "file_name".

Refer to the Octave help for these two functions.

https://octave.sourceforge.io/octave/function/run.html

https://octave.sourceforge.io/octave/function/source.html

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.
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.

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')
...