Changing initial conditions of a Simulink model when simulating using a for loop
10 ビュー (過去 30 日間)
古いコメントを表示
I am trying to run a vehicle simulink model (taken from here) for 5 seconds. When I try running it directly, the response seems to make sense.
However, when I use a for loop to do the same using a for loop (see attached runExample.m), the response is quite different. My assumption is I am not changing the initial conditions after each loop properly. Is there a way to update the initial conditions automatically instead of the way I am doing it, i.e., manually? What other ways could I trye to have the same responses with and without the for loop?
All the relevant files are uploaded. Simply set runDirect in the runExample.m file to true to run without the for loop, otherwise, set it to false.
Thanks in advance for your time. Looking forward to get some solution.
3 件のコメント
回答 (1 件)
Paul
2023 年 6 月 11 日
Why do you want to do this: instead of running the whole model in one-go, run the model for each time step, i.e., dt = 0.1 s, using for loop by passing the final boundary condition as the initial boundary condition at the end of the loop.
Is there a need to take action at the end of one time step and before starting the simulation for the next time step? Asking because there may be an alternative to accomplish whatever the goal is.
4 件のコメント
Paul
2023 年 6 月 14 日
In this line
set_param(DynamicModel, 'SaveFinalState', 'on', 'FinalStateName', 'xfinal', 'SaveFormat', 'Structure with time')
DynamicModel is not in quotes as would be typical in set_param usage. Are you sure it shouldn't be
set_param('DynamicModel', 'SaveFinalState', 'on', 'FinalStateName', 'xfinal', 'SaveFormat', 'Structure with time')
参考
カテゴリ
Help Center および File Exchange で Automotive Applications についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!