Effacer les filtres
Effacer les filtres

How to export data from simulink

4 vues (au cours des 30 derniers jours)
HamidReza Saleh
HamidReza Saleh le 19 Sep 2016
Commenté : HamidReza Saleh le 22 Sep 2016
Hi
Im trying to export data from my simulink i created an M-file that use For loops and set_param command to configure different setting such as different KM different resistance for fault ... etc then run Simulink and get data as this M-file uses for loop my first concern is overwriting data and by it i mean losing some data ? would this happen ? considering that i use several out block that fill yout parameter , do you gusy have some idea or suggestion for this ?? is there any that i can gather data from my simulink model without configuring and ruining by manual for several times ??
thanks

Réponse acceptée

Nihar Deodhar
Nihar Deodhar le 20 Sep 2016
This could be done by simply setting the output of simulation to be a vector.
set the max number of simulation s to be performed (i).
model = 'type_model_name_here';
load_system(model);
i = 100; % say you have 100 simulation runs
simout_a(i) = Simulink.SimulationOutput;
for j=1:i
set_param([model '/Constant1'], 'Value', num2str(var(j)));
set_param([model '/Constant2'], 'Value', num2str(var(j)^2));
set_param([model '/Constant3'], 'Value', num2str(var_2(j)));
simout_a(j) = sim(model, 'SimulationMode', 'normal');
end
When you need output for Nth simulation, just index simout(N).time or simout(N).datalog

Plus de réponses (1)

HamidReza Saleh
HamidReza Saleh le 20 Sep 2016
Do you have any idea how to do this ?? as you can see there is a lot of parameter and three table in one what is you're suggestion ??
  9 commentaires
Nihar Deodhar
Nihar Deodhar le 22 Sep 2016
First off I did not see a line at the beginning that say something like:
simout_a(i) = Simulink.SimulationOutput;
Ok, lets say you have it somewhere (because you have to initialize the output array).
Furthermore, You are adding output to simout_a only in one case (j=11). Doing this will only give you one simout_a(11) struct with contents and the others will be empty. So I think what you intend to have is the sim command outside of if-else statement. Aslo, if-else statement chain should have the last 'else condition' not an 'elseif'. This is not a thumb rule, but just wanted to add the last point.
HamidReza Saleh
HamidReza Saleh le 22 Sep 2016
Thanks

Connectez-vous pour commenter.

Catégories

En savoir plus sur Programmatic Model Editing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by