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

15 visualizaciones (últimos 30 días)
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 comentarios
ser
ser el 24 de En. de 2020
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 el 24 de En. de 2020
Editada: stozaki el 24 de En. de 2020
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

Iniciar sesión para comentar.

Respuesta aceptada

stozaki
stozaki el 20 de En. de 2020
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

Más respuestas (0)

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by