Plotting a graph in app designer using simulink

I have problem to plot a easiest graph in app designer. In simulink i made simple model of sinWave as input, and 'to workspace' named 'Sin' as output, in design view i have 2 Edit Fields, UIAxes and Button. I found on the solution on internet, but doesn't work when i try it. Here is my sintax in app designer: Assignin('base','U',app.EditField.Value); simout = sim('exmpl','StopTime', num2str(app.durationEditField.Value)); Plot(app.UIAxes,simout.Sin.Time,simout.Sin.Data); What can be a problem? I realy don't understand why it doesn't work.

 채택된 답변

Sabereh
Sabereh 2022년 9월 7일
Use 'output' instead of 'to workspace'.
function startupFcn(app)
h = load_system('test');
%test
end
% Button pushed function: runButton
function runButtonPushed(app, event)
simout = sim('test');
assignin("base","simout",simout);
plot(app.UIAxes,simout.tout,simout.yout{1}.Values.Data);
end
end
Here is the result:

댓글 수: 3

Thank you very much on your help. Now when i tried this, yout is empty, and i can't plot a graph, tout is there, and i can access it. Do you know ehat can be a problem? And why is yout empty?
In different versions of MATLAB, the name yout may be different. Send simout to work space using assignin and then check the exact name of your data.
Thank you again on your answer, it was very helpful tu me. Atribute actualy is named yout and was empty matric, and now i figured out why, but it steel doesn't work. I will probably find out what is problem, after your help all the time.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Simulink에 대해 자세히 알아보기

질문:

2022년 8월 30일

댓글:

2022년 9월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by