How specify simulink step time based on data array or time series

I have some sets of data I would like to input to simulink. These data interval varies in time step size. Ex.
t = [0; 15e-3; 30.1e-3; 45.1e-3]
For each these times there is 2 datasets which each is a bus signal, ex.
data1 = [0 0 0 0 0 0 0;
2 3 4 2 4 2 5;
3 4 2 3 4 5 2;
2 4 2 3 2 4 2;]
data2 = [200 203 199 206 202 220 204;
201 190 194 202 208 222 201;
203 205 197 205 203 223 205;
199 208 198 210 206 224 202]
How do I tell simulink to use these step times maps the data to port in simulink? Do i run with fixed or variable step size or something else?

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 25 Sep. 2017

0 Stimmen

Create tdata1 = [t, data1] and tdata2 = [t, data2] . Use the From Workspace block to import tdata1 and tdata2 . When you import a numeric matrix, the time of the sample is taken from the first column of the matrix. Make sure that you set the Interpolation mode as appropriate for your situation.

6 Kommentare

Yes, that is also my thought but I cannot get it to work. How should should I set solver options? If use variable I get more time intervals than specify and if use fixed I have to specify the interval but that is what is variable
It sounds as if you are trying to use Simulink as a procedural system, "do this at this time, using these steps". It is not designed for that: it is designed for simulating continuous systems in which all actions are simultaneous unless delays are specified; or for simulating discrete systems in which all actions at the same timestep are simultaneous. Simulink does a lot of algebraic work to solve for the conditions under which all of the conditions in a feedback loop can be true simultaneously.
There are various approaches you can use. One of the ways is to allow variable timestep output but build in ways such that the result is only sampled at particular times. If the particular times to be sampled at are the times from the input, t, then chances are that you are trying to use Simulink procedurally instead of as a model system.
I see what you mean and you might be right. I am not starting with "real" continous signals since "original data" are sampled at 24Mhz and the model I want to simulate only need to be run at time intervals of the 1. harmonic to minimize simulation time.
The input signal has been preprocessed to contain 128 samples at periodic interval of the 1. harmonic. So it is discrete signals.
Fixed timestep discrete samples would call for a fixed-timestep discrete solver; https://www.mathworks.com/help/simulink/ug/types-of-solvers.html#bsfsnqt
Note: the t that you showed is not fixed timestep. diff(t) is not constant.
Hello Rasmus, I am trying to simulate a model with logged timesteps and corresponding data in Simulink.
Did you get the work around to get the simulink to trigger simulation only at these pre-detemined timesteps?
Thanks,
Sanjay
Hi
Sorry I cannot remember, but do not think I did.I toke another approach with pure matlab I guess.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by