How to set the Simulink runtime and time steps from the workspace

조회 수: 24 (최근 30일)
I'm trying to perform sensitivity analysis on a model I developed in Simulink.
I establish all the constants in an m-file and use a for loop to call the Simulink model to run. Upon completion of each run, the results (time and variables) are stored in an array. I'm using the ode45 solver and the variable time step option.
The problem is that for each Simulink run the time-steps, and therefore the number of data points, are different. This presents a dimension mismatch in the array I'm saving all the values to.
An easy fix would be to chose a fixed-step option. However, when I do this, I run into a singularity issue with a few of my integrations.
Is there a way to use the time output from my initial Simulink run as the basis for all other subsequent runs? That would mean, saving the time output from the initial run in the workspace and then feeding it back to Simulink.
Alternatively, is there a way to set my time so that the data collected from Simulink model (even though it is running at variable time-step) matches the time steps I choose? For example, if I set my time from t = 0:1:50, I'll get 51 data points corresponding to those time steps.

채택된 답변

Arnaud Miege
Arnaud Miege 2011년 6월 2일
I would advise you to set the output options (Simulation -> Configuration parameters, Data import/export tab) to "produce specified output only". That allows you to have data logged with a fixed time step even though you are still using a variable-step solver.
HTH,
Arnaud
  댓글 수: 2
Christopher
Christopher 2011년 6월 2일
Arnaud, Thanks for this.
Robson Ferreira de Arruda
Robson Ferreira de Arruda 2019년 10월 11일
Sorry but it don't work .
The interval that you need to avoid is not erased .
Can you help with another way to do this ?
Thanks !

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Sources에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by