필터 지우기
필터 지우기

How to export data from simulink

조회 수: 4 (최근 30일)
HamidReza Saleh
HamidReza Saleh 2016년 9월 19일
댓글: HamidReza Saleh 2016년 9월 22일
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

채택된 답변

Nihar Deodhar
Nihar Deodhar 2016년 9월 20일
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

추가 답변 (1개)

HamidReza Saleh
HamidReza Saleh 2016년 9월 20일
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
Nihar Deodhar
Nihar Deodhar 2016년 9월 22일
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 2016년 9월 22일
Thanks

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

카테고리

Help CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by