simulink from file source block
8 次查看(过去 30 天)
显示 更早的评论
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:
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,
0 个评论
采纳的回答
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.
2 个评论
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 Center 和 File Exchange 中查找有关 Sources 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!