Borrar filtros
Borrar filtros

How to set the data from file

2 visualizaciones (últimos 30 días)
Vivi
Vivi el 25 de Jul. de 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.

Respuesta aceptada

dpb
dpb el 25 de Jul. de 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.

Más respuestas (0)

Categorías

Más información sobre Computer Vision with Simulink en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by