필터 지우기
필터 지우기

Calculate stuff during Simulink-Simulation

조회 수: 2 (최근 30일)
MarinoM
MarinoM 2018년 9월 2일
답변: Sara Nadeau 2018년 9월 4일
Hi,
I have a model of a back-to-back converter, out of which I'm sending two variables to my Matlab workspace (the last 200.000 values, since with the sample time of 0.0000001s it is only all the values from a complete period). I run the simulation once, and then I have two variables in my workspace. I'm using these variables as vector and I'm calculating a few things with them, like calculating the RMS of one and taking the Max value minus the min value of the other vector, and a bit more and giving these two single (!) values that I get into another Matlab Function that returns one value.
Now I want that to happen on the go, during a Simulation (Tsim = inf). I know that I can pause a Simulation, calculate and then continue, but is there an option to do all this on the go?
The Matlab Function block seems to be the right way, but I have the problem that I need the last 200.000 values of a current, not only the one current value of it.
So how do I save 200.000 values into a vector, inside a Matlab-Function-Block to use them in real (simulation) time? I don't want to do anything with the result of the Function, only display it.
Doing all the calculations in Simulink Blocks doesn't seem to be a good way either, especially since I need one RMS Value of the current, which is not working because of some error because of the sample time...

답변 (1개)

Sara Nadeau
Sara Nadeau 2018년 9월 4일
What version of Simulink are you working with? In 18a, you can use the Data Access feature to process logged signal data during simulation. You would write a callback function to specify in the Instrumentation Properties for your logged signal. The callback would handle selecting and/or accumulating the samples and then calculating the RMS value. You could use the assignin function to display the calculated results in the MATLAB workspace.

카테고리

Help CenterFile Exchange에서 Sources에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by