variables in Simulink Workspace

Hi,
I have created a variable 'simout' with the To Workspace block in Simulink. Now I have to use this in a m file, but an error indicates that 'simout' is not defined. How to import this in a m file?
Thanks Senmeis

回答 (4 件)

Kaustubha Govind
Kaustubha Govind 2012 年 10 月 19 日

1 投票

Please see my answer here to a similar previously asked question.
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 10 月 19 日

0 投票

If it's In workspace, means it's recognized by m file. check your to workspace block, then set save format to array
dimitris
dimitris 2012 年 10 月 19 日

0 投票

Simulink resolves variables from base workspace, so if you use simout from a function it wont be able to 'see' it because functions use their own workspace. The following link might help you.
Owen
Owen 2012 年 10 月 22 日

0 投票

My goal is, simulate a model with 'sim()' in an m file, but the variable 'simout' seems not to be defined in the m file, which is created by the To Workspace block.
I tried
assignin('base', 'my_simout', simout)
and
assignin('caller', 'my_simout', simout)
but it doesn't work. I think 'simset()' also won’t work.
I noticed that all the variables created by the 'To Workspace' block won't be seen in the Matlab Workspace if the simulation is started in an m file. Any ideas?
Thank Senmeis

2 件のコメント

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 10 月 22 日
編集済み: Azzi Abdelmalek 2012 年 10 月 22 日
Owen, Variables from to workspace block are seen by any m file, (except Functions). Check if your variable is simout and not Simout or any typo error. To be sur rename it 'x' for e.g
Kaustubha Govind
Kaustubha Govind 2012 年 10 月 23 日
編集済み: Kaustubha Govind 2012 年 10 月 23 日
Oops, I meant to say that you need to use:
options=simset('SrcWorkspace','current','DstWorkspace','current');
sim('mymdl',[0 duration],options)
So that 'To Workspace' writes to the function workspace.

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

カテゴリ

ヘルプ センター および File ExchangeInteractive Model Editing についてさらに検索

製品

タグ

質問済み:

2012 年 10 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by