Azzera filtri
Azzera filtri

Simulate model several times

1 visualizzazione (ultimi 30 giorni)
mwer
mwer il 25 Gen 2017
Modificato: avleed il 30 Gen 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 Commenti
mwer
mwer il 27 Gen 2017
no one?
Sruthi Geetha
Sruthi Geetha il 30 Gen 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.

Accedi per commentare.

Risposte (1)

avleed
avleed il 30 Gen 2017
Modificato: avleed il 30 Gen 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

Categorie

Scopri di più su Modeling in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by