필터 지우기
필터 지우기

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 CenterFile Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by