Changing initial conditions of a Simulink model when simulating using a for loop
조회 수: 9 (최근 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!