Plot to axes from a simulink variable
古いコメントを表示
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
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
2012 年 1 月 30 日
回答 (1 件)
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 件のコメント
Nuno Agualusa
2012 年 1 月 31 日
Kaustubha Govind
2012 年 1 月 31 日
Nuno: Yes, your problem is clear to me. The problem is that Simulink creates the 'simout' variable in the base workspace by default. To verify this, use "simout = evalin('base', 'simout');" after the SIM command - this will copy the variable from the base workspace to the GUI function workspace and make it available for plotting. Try:
opts = simset('DstWorkspace', 'current');
sim('Sistema_s_Atraso_SelfTuning',tempo_simulacao, opts);
Nuno Agualusa
2012 年 2 月 1 日
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
2012 年 2 月 1 日
カテゴリ
ヘルプ センター および File Exchange で Event Functions についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!