Effacer les filtres
Effacer les filtres

How to set the data from file

2 vues (au cours des 30 derniers jours)
Vivi
Vivi le 25 Juil 2013
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.

Réponse acceptée

dpb
dpb le 25 Juil 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.

Plus de réponses (0)

Catégories

En savoir plus sur Computer Vision with Simulink dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by