simulink from file source block

2 views (last 30 days)
Mark
Mark on 18 Jun 2012
I am trying to load some data that is generated in matlab into a source "from file" block in simulink. I use the following statement in my matlab script to save the data:
save awng.mat Y_awgn_scale -v7.3;
I tried a few different flavours with saving the time step etc and none of it works. I can load the data into the workspace which shows the data in awng.mat to be a one dimensional array of type double:
Y_awgn_scale double
However, If I specify the file name in a "from File" source block, upon trying to load, I get an error message:
Simulink does not support loading the input data in file 'C:\Users\marka\Documents\MATLAB\awng.mat'. Simulink can only load two-dimensional arrays or timeseries objects. The array must consist of one-dimensional, double, noncomplex samples. To load data having a different type, complexity, or dimension, use a timeseries object. For either an array or a timeseries object, at least one sample point is necessary.
This error message is confusing. Does the array needs to be two dimensional or one? I tried adding a variable that had the time stamp and it did not do anything. I have left all the settings in the "fromFile" simulink block as default. I am using 2012a release.
Can you post a sample file that is read in or specify what save command needs to be used to save a simple array of data of type double I need to use so that I can load it into "from file" source?
Thanks,

Accepted Answer

TAB
TAB on 18 Jun 2012
To read data from a MAT-file, should be in Time Series * or *Time and Value array format.
Just save some simulation data using To file block into a MAT file and analyze this data to understand the required format. To workspace block saves data in Time and Value array format which contains Time array is Row1 and Data arrays are other Rows.
See From File for details.
  2 Comments
Mark
Mark on 18 Jun 2012
Thanks for the reply. I did this and yes I cna read this back in simulink. Since the file is binary, that does not help me in terms of what I am trying to do and I cannot do any "analysis" on it.I am trying to import some data from a matlab script and it is a simple one dimensional array of type double. I thought I should be able to do this without time series.
Again, if any one can share a save format that they have used in matlab script, I will be greatful.
TAB
TAB on 18 Jun 2012
I know the MAT files are binary files.
From "Analyse the data" i mean, load the MAT file (which was saved by To File block) into matlab workspace, type the name of variable (which was entered in the To File block's "Variable name" field) on command window and check how array is formatted. Same format or array (ie Data with time) can be read with From file block.

Sign in to comment.

More Answers (0)

Tags

Products

Community Treasure Hunt

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

Start Hunting!