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.

Parameterize function-block via m-File

0 votes

I use a m-File to write a function in the function-block in PLECS. The input variable of the function has to be a value that is recalculated in each simulation-step in PLECS. The problem is that I need to have this variable in the m-File.

How can I get a PLECS-Variable  that changes in every simulation step to the Matlab workspace?

The "To File" Block is not suitable because it gives course of the variable back after the whole simulation but I need this variable after every time step to feed in the function.
asked Dec 29, 2022 by utuber27 (22 points)

1 Answer

0 votes
Best answer
In MATLAB and Simulink there is not a means to have the time-step by time-step results available in the MATLAB workspace in a manner where it interacts with the Simulink simulation model in a closed-loop fashion.

I recommend reading about S-Functions in MATLAB if you would like to integrate an algorithm written in MATLAB into a Simulink model.

Then one could have the relevant signals from the PLECS portion of the model made available via Inports and Outports and fed to the S-Function block.

Depending on the nature of the function, one could also implement it in PLECS or Simulink blocks as well.
answered Jan 3, 2023 by Bryan Lieblick (1,995 points)
selected Jan 3, 2023 by utuber27