How can I make a file that Simulink's "From File" block can read?

1 回表示 (過去 30 日間)
Milo
Milo 2014 年 8 月 11 日
コメント済み: Milo 2014 年 8 月 11 日
I'm trying to use use Simulink's "From File" block and I can't get it to read any of the .mat files I create.
I have two vectors of equal length, one is a timestamp, the other is a data value. The vectors are quite long, but as an example, I'll use the following:
t = (1/32).*[ 1 2 3 4 5 6 7 8 9 10]';
v = [1.123 1.125 1.235 1.443 1.135 1.123 1.125 1.235 1.443 1.135]';
I've tried the following .mat files:
b = timeseries(v, t);
save('b.mat','-v7.3')
and:
b = [t,v];
save('b.mat','-v7.3')
both ways I've tried it I get the following error message:
"Simulink does not support loading the input data in file 'b.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."
How do I get these two vectors into a format that Simulink can read? Thanks for your help.

採用された回答

Adriano Bittar
Adriano Bittar 2014 年 8 月 11 日
Try this :
v = timeseries(v, t, 'name', 'Vector1')
save v -v7.3 v
  1 件のコメント
Milo
Milo 2014 年 8 月 11 日
This worked. Thank you.
Can anyone explain why this worked but the timeseries approach I used above didnt?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSources についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by