How to extract data from simulink to work space in matlab?

20 ビュー (過去 30 日間)
Pramod Sapkota
Pramod Sapkota 2020 年 6 月 1 日
回答済み: khalid elamin 2021 年 1 月 12 日
I tried to design a LQR controller. I wrote the code and design a simulink model.
I wanted to extract data from simulink to workspace.
But when i run the code it says error in time which i have written as t= sim_X.time.
How can I solve the issue?
I have attached the screen shot below.
  2 件のコメント
Sugar Daddy
Sugar Daddy 2020 年 6 月 1 日
make sure it is sim_X.time or sim_X.Time or sim_X.tout. Visualize it in workspace
Pramod Sapkota
Pramod Sapkota 2020 年 6 月 1 日
so, this is my simulink model
since, i realise, there is out.sim_X in workspace, i changed myy code to
t= out.sim_X.time which was previously written as t=sim_X.time
i still get the same error.
"Unable to resolve the name out.sim_X.Time.
Error in codeviayoutube (line 84)
t=out.sim_X.Time; "
what is wrong? is there any other command ?

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

回答 (2 件)

Ameer Hamza
Ameer Hamza 2020 年 6 月 1 日
  2 件のコメント
Pramod Sapkota
Pramod Sapkota 2020 年 6 月 1 日
I used the same block to workspace.
But still i get the same error when i changed to t= out.sim_X.time
Ameer Hamza
Ameer Hamza 2020 年 6 月 2 日
Have you selected "Timeseries" as save format inside the To workspace block?

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


khalid elamin
khalid elamin 2021 年 1 月 12 日
Try this:
simOut =sim('simulinkviayoutube')
t = simOut.sim_X.time;
x1 = simOut.sim_X.signals.values(:,1);
x2 = simOut.sim_X.signals.values(:,2);
it will help you !!

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by