フィルターのクリア

To Workspace block does not return any result when I simulate the modelo from App Designer

7 ビュー (過去 30 日間)
Hello,
I am developing a simple User Interface with App Designer to control a Simulink Model. The problem is that excuting the sim () function, the simulink models starts simulating but It does not send the results to Matlab Workspace. If I execute the model directly from Simulink there is no problem.
Is there any function that returns "To workspace" data when executing from App Designer?
Thank you!

回答 (2 件)

Jyotirmay Mishra
Jyotirmay Mishra 2020 年 6 月 22 日
Hi Maria,
Yes it is possible to send the simulation data to workspace from inside the appdesigner. For that use a 'to workspace' block in your simulation model. Then in your appdesigner, you can use assignin function to assign the output to any workspace variable.
For example - simout = sim('SineWave_SL');
assignin('base', 'Data_Time', simout.SineWaveValue);
In the above case 'SineWave_SL' is the name of my model. The model has a sine wave whose output is connected to the 'to workspace' block. The assignin function takes workspace name, variable name, data as arguments. In the above case, the workspace is 'base', 'Data_Time' is the varible and simout.SineWaveValue(where SineWaveValue is my 'to workspace' block name in the model) is the data.
You can refer to this link to know more about assignin function -: https://www.mathworks.com/help/matlab/ref/assignin.html
I hope this solves your problem.
  6 件のコメント
Maria Munilla Fernandez
Maria Munilla Fernandez 2020 年 6 月 22 日
Thank you very much! It works
Jyotirmay Mishra
Jyotirmay Mishra 2020 年 6 月 22 日
Great
Please mark the answer as accepted

サインインしてコメントする。


KARETI NAVEEN KUMAR
KARETI NAVEEN KUMAR 2021 年 8 月 24 日
Hi..my simulank data is not shifted to workspace

カテゴリ

Help Center および File ExchangeSimulink Environment Customization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by