필터 지우기
필터 지우기

Interact with simulink from Matlab

조회 수: 4 (최근 30일)
David Gonzalez
David Gonzalez 2019년 3월 25일
답변: Carlos Sanchis 2020년 2월 18일
I have a model of a inversor in simulink and I control multiple variables from Matlab workspace.
Now I want to start the simulation and after 'x' time pause them, export to the workspace some signal (this signal goes to a ToWorkspace block), after that clean all variables in simulink, introduced new variables from the workspace and finally continue the simulation.

답변 (3개)

Mauro Fusco
Mauro Fusco 2019년 3월 25일
Hi,
you can use sim('model.slx',PARAMETERS) to simulate your model. You can also specify the duration of your simulation. Once you get the data, you can re-use sim again for passing new parameters and get corresponding data. Look into sim documentation (doc sim) for more detalis.

David Gonzalez
David Gonzalez 2019년 3월 26일
Hi,
Thanks for your answer. I tried it but with sim('model.slx',PARAMETERS) the pause command doesn`t work.

Carlos Sanchis
Carlos Sanchis 2020년 2월 18일
Another way to do this is to make paremeters live in the MATLAB workspace as variables and just change them in between simulations. If you want the simulation to run for a set number of 'x' seconds, you can make StopTime a variable too. To get the resulting signals, yo can mark them for logging and retrieve them with the sim command like this:
param1 = 33;
param2 = 57;
stopTime = x;
[t1, signals1] = sim('yourModelName');
param1 = pi;
param2 = 0.5;
stopTime = x;
[t2, signals2] = sim('yourModelName');
By default, signals are columns in the second output, although that can be changed in the model settings.
Attacched is an example of this approach.

카테고리

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