How to access time step in simulink model?
조회 수: 307 (최근 30일)
이전 댓글 표시
I want to make a Matlab function in simulink model. In this function I want to calculate relative acceleration between two cars,but to do this I will need to divide the relative velocity with time step. How could i do this?
댓글 수: 0
답변 (3개)
Jeff Chang
2022년 3월 27일
I use the following loop to calculate variable-step time step differences
The memory block will store and output the previous time stamp and the subtract block will subtract current time from previous time to output time difference.
For example, I have a 1DoF rocket launch simulator, which outputs height, velocity and acceleration on the left, and the time step taken to calculate the output is plotted on the graph on the right indicating I'm using a variable step calculator at the time.
댓글 수: 0
Sebastian Castro
2015년 8월 26일
I wouldn't really recommend using MATLAB Function blocks to approximate derivatives, given that Simulink blocks have much better support for time-based integration...
My unsolicited preaching aside: If you want to pass in the simulation time into the MATLAB Function block, you could use a Clock from the Simulink > Sources library.
- Sebastian
댓글 수: 0
Aseem Routray
2021년 5월 25일
You can access the step size from the model configuration parameters using the command:
get_param(bdroot,'FixedStep')
This should work if the solver settings have been chosen as a fixed step solver. You can right click on any parameter in the configuration parameters and then click on 'What's This?' to get the command line for setting the parameter using matlab commands.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Sources에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!