Trouble about importing data using 'From File' block in simulink

8 views (last 30 days)
Hi Everyone,
I've a data that is logged from my hardware. The data consists of two items. One is the 'time stamp' and the other is the 'real data'. Here, 'time stamp' represents the sample time at which the 'real data' has been sampled. The sample time is 10ms. But as you know, in the logged data, it is not exactly 10ms all the time.
Anyway, I'd like to import this data to my simulink model. So, I converted this data to store in a *.mat file such as the 1st row contains 'time stamp' data and the 2nd row contains 'real data'.
Now, using the 'From File' block, I'm loading this data to my model (I have a total of around 10,000 samples of both 'time stamp' and 'real data' each). I set the 'Sample time' parameter of 'From File' block as '0.01' and I set a value of '100' for 'Simulation stop time'.
And now, using the 'To File' block, I'm storing this data again back to a *.mat file to check how my data has been using by my model. I observe, that the data is not same as my real data. I think simulink is doing some interpolation if 'time stamp' in my input data file is not matching to the sample time of 'From File' block. But, I'd like my model to use exactly the same data as in my input file.
Is there anything that I'm doing wrong here? Also, I'm not quite sure, if I'm configuring all the parameters properly here(like 'Sample time' of 'From Block' or 'Simulation stop time' etc).Is the 'Simulation stop time' here is based on no. of samples that I've in my input data file and 'sample time' of data?
Could you please suggest your ideas on my process that I'm using now.I'm pretty new to Simulink, and I try to read many articles about this, but still not very clear about my process.
I'm using 'Fixed-step' solver with '0.001' as 'fundamental sample time' i.e. Sample time of my model is 1ms.
Thank You

Accepted Answer

Kaustubha Govind
Kaustubha Govind on 14 May 2012
As you mentioned, your time stamps are not exactly at 10ms all the time. What if you fudge the time-stamps of the input signal so that they are exactly 10ms apart? Does this fix the interpolation issue?
Also, you can turn on Sample Time Colors on your model to make sure that the "From File" block is indeed running at 10ms.
  3 Comments
Kaustubha Govind
Kaustubha Govind on 14 May 2012
The warning is saying that you don't need ode1 because you don't have any continuous states in your model. It is sufficient to pick the FixedStepDiscrete solver which Simulink is doing for you automatically. You can switch to this solver yourself so the warning isn't displayed.

Sign in to comment.

More Answers (0)

Categories

Find more on Simulink Environment Customization in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!