How to set the data from file
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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.
0 Kommentare
Akzeptierte Antwort
dpb
am 25 Jul. 2013
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Computer Vision with Simulink finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!