How to load a two-dimensional array using 'From File ' block in Simulink

조회 수: 15 (최근 30일)
ser
ser 2019년 12월 28일
편집: stozaki 2020년 1월 24일
I am trying to load 2x180 matrix using 'From File ' block and then display it with 'Scope' block in Simulink
the first row of the matrix includes time values [-5.0002 :0.0002: -4.9644 ] and second row includes corresponding amplitude values.
I saved the 'signal_5' (in the attachment) as 7.3 MAT-file format.I arranged the matrix to comply with the following link:
how should I set 'Sample Time' and Simulation Stop time? or any other parameters
Although I tried to do it, I could not display amplitude plot.
  댓글 수: 4
ser
ser 2020년 1월 24일
Thanks a lot for your effort
Since I have Matlab 2017a, by temporarily disabling "Do not load models created with a newer version of simulink" option from "Model File Preferences" and loading the model and the "signal_5.mat" file you attached, I was able to save as 2017 version. Then, I ran it and It worked successfully.
One minor question is : When I display the "signal_5" in scope in the model and compare it with that of plotted using MATLAB. The waveforms somewhat different. Is there any explanation of this difference?
I send the both of figures as an attachment
Best Regards,
stozaki
stozaki 2020년 1월 24일
편집: stozaki 2020년 1월 24일
Thanks your suggenstion.
Waveform differences are the effect of sampling. The time interval of the data stored in the .mat file is 0.002. In Simulink, the sample rate is 0.002. This seems reasonable when simulating discrete systems.
However, when simulating a continuous system with Simulink, the solver needs to be changed. I attached an example.
When simulating with Simulink, please set an appropriate solver type of configuration set.
This issue is independent of the tool version.
Regards,
stozaki

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

채택된 답변

stozaki
stozaki 2020년 1월 20일
Please download model and .mat file attached. (created by R2019b)
And execute following script.
model = 'signal_5model'; % define model name
open_system(model); % open model file
cs = getActiveConfigSet(model); % get active congiguration set from model
set_param(cs,'FixedStep','0.0002'); % set sample rate
sim(model,...
'StopTime','0.036'); % simulate until 0.036
The oscilloscope triggers while sweeping the data continuously. Therefore, I think that the data before and after the time to trigger is acquired.On the other hand, Simulink always starts simulation at time 0. Therefore,I modified the format of the data.
Regards,
stozaki

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Scopes and Data Logging에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by