Azzera filtri
Azzera filtri

Fill data with NaN

1 visualizzazione (ultimi 30 giorni)
Danilo M
Danilo M il 23 Lug 2018
Risposto: Adam Danz il 23 Lug 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.

Risposta accettata

Adam Danz
Adam Danz il 23 Lug 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.

Più risposte (0)

Categorie

Scopri di più su Numeric Types in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by