フィルターのクリア

How to set the data from file

2 ビュー (過去 30 日間)
Vivi
Vivi 2013 年 7 月 25 日
I have some data saved as .dat file from 1sec to 3600sec. I would like to read this data in simulink. Then I write the code to read the file and its work perfectly. The code is:
indata=load(file name)
time=indata( : , 1);
d=indata( ; , 2)
...
The problem is the time of file is from 1sec, I would like to put time 0 before the first second. for example the file is:
1 0.3 1.7
2 0.5 0.9
...
3600 X X
so how to write the code to add: 0 0 0 before 1 0.3 1.7 in Matlab and then run the simulink.

採用された回答

dpb
dpb 2013 年 7 月 25 日
ndata=load(file name)
ndata=[zeros(1,size(ndata,2); ndata]; % prepend row of zeros
time=indata( : , 1);
...
Note the use of zeros() and size(ndata) -- this will be consistent w/ a different number of columns in the input file if that were to change rather than just writing
ndata=[[0 0 0]; ndata]; % prepend row of zeros
or using a hardcoded '3' in the zeros() argument.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeComputer Vision with Simulink についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by