0
votes

I am facing a problem using the data imported into the workspace for my Simulink blocks.

My Case:

I did a simple block diagram to simulate the results before implementing this method to the actual Simulink blocks. I made use of a 'From workspace' block to read in the data and a scope to observe the output. These are the settings:

t=0:22/565:22
a.time=t
a.signals.values=ddata   %ddata contains [565x1] datas
a.signals.dimensions=1;

I realized that the results in the scope doesn't match the data.

I found out that on this website (http://blogs.mathworks.com/seth/2012/02/09/using-discrete-data-as-an-input-to-your-simulink-model/) the steps taken by the Simulink solver are different from the ones specified in the input time vector.

Attempt to solve:

I set the time vector to zero but there is an error.

a.time=[];

Error: "Invalid continuous sample time specified for'test/From Workspace'. Continuous sample time is not permitted when the input from workspace is a structure with no time data. To eliminate this error, select a discrete sample time or change the input data to include time data. "

Questions:

  1. How do I resolve this error without using time vector?

  2. What is the best way to read one row for each time step into the Simulink block instead of a whole list of data?

I greatly appreciate if anybody can provide insight/solutions/alternative method to my case.

2
What does your model do? Does it actually have continuous states? If not, you should change the solver to FixedStepDiscrete, which may well fix your problem.wakjah
My model is a perspective non-linear observer. The inputs are discrete but the model works as a continuous model. Does that makes a difference to the settings?Ko user1744439

2 Answers

0
votes

The time vector in your data has little bearing on the time steps that Simulink will use when simulating the model. Think of your input time/data as a look-up table that Simulink will use to obtain an input value (using interpolation) for each time step (that it decides to take).

To force Simulink to take steps at given time points then you need to change the parameters on the Solvers page of the Configuation Parameters dialog. It sounds like you want to use a fixed-step solver with a step size of 22/565.

0
votes

Maybe you could work with a 1-D Lookup Table block? Where you use the time vector as Breakpoints and the ddata as Table data. If Simulink has a time point in between points in the time vector, you could use linear/cubic interpolation or use the nearest point. In this manner you avoid forcing Simulink to certain time points.

enter image description here