Borrar filtros
Borrar filtros

Fill data with NaN

1 visualización (últimos 30 días)
Danilo M
Danilo M el 23 de Jul. de 2018
Respondida: Adam Danz el 23 de Jul. de 2018
I have temporal series matrix data(:,8) with the format [yyyy mm dd hh mm ss rain], and I want to fill missing data with NaN with this code:
dt=datetime(data(1,1:6)):minutes(15):datetime(data(end,1:6)); dt=dt.';
t=table(dt,nan(size(dt)),'VariableNames',{'data','prec'});
ix=ismember(t.data,datetime(data(:,1:6)));
t.prec(ix)=data(:,end);
When I work with short periods [data(7000,8)], the script works fine, but for larger matrix [data(35000,8)], returns this error when run the last line:
"In an assignment A(:) = B, the number of elements in A and B must be the same."
There's some way to correct this?
I'm using R2017b version.

Respuesta aceptada

Adam Danz
Adam Danz el 23 de Jul. de 2018
In this line
t.prec(ix)=data(:,end);
you're trying to put all the data from the last column of 'data' into only 6 or less available indices of t.prec. The reason I think it's only 6 indices is because ix is a logical index of length 6 and some of those indices may be false. 'ix' is only 6 long because t.data is only 6 long as you can see in dt=datetime(data(1,1:6)) ...
This is a guess since I can't run your code.

Más respuestas (0)

Categorías

Más información sobre Numeric Types en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by