Plot to axes from a simulink variable

조회 수: 2 (최근 30일)
Nuno Agualusa
Nuno Agualusa 2012년 1월 30일
Hi,
I'm trying to plot a variable from simulink in a axes GUI, and that what's happening:
I put the simulation running trought GUI with this command: [timeVector,stateVector,outputVector] = sim('Sistema_s_Atraso_SelfTuning',tempo_simulacao);
and when the simulation ends the ouput variable 'simout' to appear in my base worspace, due to that i can't plot the resulta in my GUI axes. I'm using a variable block in simulink, to get all the data to worspace. The only way that i found to get a variable in base workspace, is to run the simulation manualy in simulink.
what can i do to read the output variable and pot in a GUI axes?
Thanks
Nuno
  댓글 수: 2
TAB
TAB 2012년 1월 30일
[I'm using a variable block in simulink]. What is "variable block" ?
Have you tried "ToWorkSpace" block?
You are runnung model manually or using "sim()" command, it dosn't make any difference in simulation output.
Nuno Agualusa
Nuno Agualusa 2012년 1월 30일
yes, it's a "ToWorkSpace" block, called "simout". i'm using the "sim()" command to start the simulation.
My objective is to get the data to plot in a axes GUI after simulation stops.
Thanks
Nuno

댓글을 달려면 로그인하십시오.

답변 (1개)

Kaustubha Govind
Kaustubha Govind 2012년 1월 31일
Try
sim('Sistema_s_Atraso_SelfTuning',tempo_simulacao, 'DstWorkspace', 'current');
This ensures that all variables created by Simulink use the current workspace as the destination.
EDIT:
The command needs to be:
opts = simset('DstWorkspace', 'current');
sim('Sistema_s_Atraso_SelfTuning',tempo_simulacao, opts);
  댓글 수: 5
Kaustubha Govind
Kaustubha Govind 2012년 2월 1일
You only need EITHER "opts = simset('DstWorkspace', 'current');" OR "simout = evalin('base', 'simout');" - not both. Using the first will cause an error in the second statement, because there is no simout variable created in the base workspace in that case.
Nuno Agualusa
Nuno Agualusa 2012년 2월 1일
It didn't work too. I don't know what to do more to solve this situation.
If you don't mind i could send to you my files just to look to them and see if i'm doing somethink wrong in other place.
Thank you very much.
Nuno

댓글을 달려면 로그인하십시오.

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by