How to export data from simulink
이전 댓글 표시
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
채택된 답변
추가 답변 (1개)
HamidReza Saleh
2016년 9월 20일
0 개 추천
댓글 수: 9
Nihar Deodhar
2016년 9월 20일
There could be several ways to access the output. First of all I would like to know the format in which you get output for a single simulation. Is it just tout and yout as timeseries, or is it a set of arrays of the form structure with time? The data extraction process will be different in each case. I have provided a code snippet below for the case when output is taken as 'structure with time'.
Lets say you have the variable names in your simulink model that you mentioned above.
for k = 1:100
fault_inception_angle_temp = simout_a(k).get('fault_inception_angle');
fault_inception_angle(k,:) = fault_inception_angle_temp.signals.values;
end
and so on for different variables. If you have a different output type, like timeseries or some other structure, then the code could be slightly modified to extract/process the output for each simulation.
HamidReza Saleh
2016년 9월 20일
HamidReza Saleh
2016년 9월 20일
Nihar Deodhar
2016년 9월 21일
if you want to see the output for simulation 1,
simout_a(1).get('yout').signals.values
the above command will give you the output.
HamidReza Saleh
2016년 9월 21일
Nihar Deodhar
2016년 9월 21일
There might be something else going on with the way you are logging your data. I save it as 'Structure with time' for which case the above code literally works fine. Here is a snapshot of what I mean. There is an option to set the format.

HamidReza Saleh
2016년 9월 21일
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
2016년 9월 22일
카테고리
도움말 센터 및 File Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
