simulink from file source block

조회 수: 6 (최근 30일)
Mark
Mark 2012년 6월 18일
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,

채택된 답변

TAB
TAB 2012년 6월 18일
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
Mark
Mark 2012년 6월 18일
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 2012년 6월 18일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Sources에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by