I'm stuck with an investigation project and I don't have experience in this situations with matlab.
I have to simulate a corrent impulse loading the data from a txt.
The txt has 2 columns, one for time, and the other for intensity.
To import this data to two variables in the workspace and plot them is easy, but the nightmare comes when I want to simulate this data.
I use the block 'from workspace' to load the two variables into simulink, but what is shown in the scope block has no sense.
I think the problem may be with 'time step' or how the time is interpreted, but as far as I have tested it I don’t get any change.
The finality of loading this data and get to simulate it properly, is to see how movs(metal oxide varistors) behaves, so next to the from workspace block I will put some inductors, resistances and the varistor block from simulink with voltage and current sensors.
I have to say that I don't use to ask for help and I look for answers by myself, but now this is getting me in trouble.
Thank you in advance/Gracias

 Réponse acceptée

Mathieu NOE
Mathieu NOE le 23 Nov 2022
hello
I tried to reproduce your problem , but got the right output , not what you show... hope the attached files can help you
I simply created a column oriented array with time in first col and signal in second col
then the simulink model has fixed time stamps (fixed solver , step = dt as declared in m file), no zero crossing detetction, no interpolation...
% some dummy data
Fs = 1e6; % 1 MHz
dt = 1/Fs ;
t1 = (-10:290)*dt; % 100 microS of data
It1 = zeros(size(t1));
It1(20:end) = exp(10000*(-t1(1:end-19)+t1(1)));
plot(t1,It1);
% prepare data for simulink to Workspace block
% For matrix formats, each row of the matrix has a time stamp in the first column
% and a vector containing the corresponding data sample in the subsequent column(s).
t_start = t1(1); % put that in simulation simulation start time
t_end = t1(end); % put that in simulation simulation stop time
simin = [t1(:) It1(:)]; % (:) this makes sure the data are column oriented

5 commentaires

Thank you!
Adding what you said make it work
Finally I added this part of the code:
Fs = 1e6;
dt = 1/Fs ;
t_start = t1(1);
t_end = t1(end);
I would like to understant why it needed this changes, for example why the variable Fs and dt.
I modified this line of code to be able to use all the data, but, I saw that erasing this line it still worked the same way, is this line to simulate just this period of time?
t1 = (-10:2000)*dt;
The next line gave me error at the beginnig, later it worked fine:
simin = [t1(:) It1(:)]; % (:) this makes sure the data are column oriented
Mathieu NOE
Mathieu NOE le 24 Nov 2022
Glad it works fine now !
Jose Manuel Velasco Sanchez
Modifié(e) : Jose Manuel Velasco Sanchez le 28 Nov 2022
@Mathieu NOE When I ran it at home it worked me, today I tried it in the laboratory with Matlab online and it don't worked anymore.
Is there a big difference using Matlab in a web browser?
%% hello - seems to be running fine even on line !
% some dummy data
Fs = 1e6; % 1 MHz
dt = 1/Fs ;
t1 = (-10:290)*dt; % 100 microS of data
It1 = zeros(size(t1));
It1(20:end) = exp(10000*(-t1(1:end-19)+t1(1)));
plot(t1,It1);
% prepare data for simulink to Workspace block
% For matrix formats, each row of the matrix has a time stamp in the first column
% and a vector containing the corresponding data sample in the subsequent column(s).
t_start = t1(1); % put that in simulation simulation start time
t_end = t1(end); % put that in simulation simulation stop time
simin = [t1(:) It1(:)]; % (:) this makes sure the data are column oriented
I will investigate it more, thank you!!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Simulink dans Centre d'aide et File Exchange

Produits

Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by