Filter löschen
Filter löschen

Simulate model several times

1 Ansicht (letzte 30 Tage)
mwer
mwer am 25 Jan. 2017
Bearbeitet: avleed am 30 Jan. 2017
I have a Simulink model consisting of 2 model parts. Assuming the simulation time is from 1 to 100s. The first model part calculates a value needed for the second model part. The thing is that the calculation of this value is completed after 100s, but is needed in the second model part at time 1s.
My question is if there is a possibility to simulate my first model part from 1 to 100s to calculate this specific value needed for my second model part and then run the second model part from 1 to 100s. So simulating those two model parts consecutively. I need to do this continuously: simulate model part 1 from 1-100s, then simulate model part 2 from 1-100s, then simulate model part 1 from 101-200s, then simulate model part 2 from 101-200s and so on.
Thanks
  2 Kommentare
mwer
mwer am 27 Jan. 2017
no one?
Sruthi Geetha
Sruthi Geetha am 30 Jan. 2017
The value from the first model part is calculated only after 100s. So you need to simulate the first model part for 100s. The second model part takes the value from first model part after 100s. So it needs to be simulated for the next 100s, ie., 101-200s. You cannot go back in time and simulate the second model part for 1-100s. You can have two Enabled Subsystems and a Timer block and give the conditions for the Enabled Subsystem in such a way that when time<=100s, enable the first subsystem and 100<time<200, enable the second subsystem and so on.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

avleed
avleed am 30 Jan. 2017
Bearbeitet: avleed am 30 Jan. 2017
Set up a "to workspace" block in your first model and in the configurations, there is an option to record only the last x values - here put in a 1 to select only the last value.
Similarly, set up a from workspace block in your second model and set it up as the same name as the variable you are exporting from the first model.
Then use a small .m script
options = simset('SrcWorkspace','base');
sim('model1',[],options) % Run model 1
sim('model2',[],options) % Run model 2

Kategorien

Mehr zu Modeling finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by