Simulink model in a for loop

Hi at all, I have a problem when I run a simulink model inside a for loop.
More in detail when I run the model with the command:
set_param('model_name','SimulationCommand','start')
the script doesn't wait the end of the simulation before continue...
There some commands like the waitfor or the drawnow?
Thanks
M1tc4

 採用された回答

Titus Edelhofer
Titus Edelhofer 2011 年 11 月 9 日

0 投票

Hi Mitch,
I would usually suggest to use the function sim for running simulations, or is there any reason you can't use sim?
Titus

5 件のコメント

Mitch Martelli
Mitch Martelli 2011 年 11 月 9 日
Yes there is a reason but i dont now if it is right , the model save the date with the 'to workspace' block ... there is a very large numbers of variables stored and i dont want to change all the 'to workspace' blocks with the 'out' blocks.
Titus Edelhofer
Titus Edelhofer 2011 年 11 月 9 日
You can use ToWorkspace blocks with sim: depending on the version of MATLAB you are running, the sim command has changed recently to make the use easier. But you can use
set_param(yourModel, 'DstWorkspace', 'current')
and then sim puts the results of the ToWorkspace blocks into your current workspace (inside your function e.g.).
Titus
Mitch Martelli
Mitch Martelli 2011 年 11 月 9 日
I try but.....
??? Error using ==> set_param
block_diagram does not have a parameter named 'DstWorkspace'.
Error in ==> Main_more at 26
set_param('PID', 'DstWorkspace', 'current')
I use R2007b
Titus Edelhofer
Titus Edelhofer 2011 年 11 月 9 日
Hi Mitch,
sorry, set_param was wrong, it's simset that you need to use
opt = simset('DstWorkspace', 'current');
and pass this to sim.
Sorry!
Titus
Mitch Martelli
Mitch Martelli 2011 年 11 月 9 日
Fantastic... I dont need to open the model... I dont need to put a pause...All the variables are stored in the workspace with the correct name...
Thanks a lot Titus

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGeneral Applications についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by