How to export data from simulink
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
HamidReza Saleh
il 19 Set 2016
Commentato: HamidReza Saleh
il 22 Set 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
0 Commenti
Risposta accettata
Nihar Deodhar
il 20 Set 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
0 Commenti
Più risposte (1)
HamidReza Saleh
il 20 Set 2016
9 Commenti
Nihar Deodhar
il 22 Set 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.
Vedere anche
Categorie
Scopri di più su Programmatic Model Editing 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!