Filter löschen
Filter löschen

Fill data with NaN

1 Ansicht (letzte 30 Tage)
Danilo M
Danilo M am 23 Jul. 2018
Beantwortet: Adam Danz am 23 Jul. 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.

Akzeptierte Antwort

Adam Danz
Adam Danz am 23 Jul. 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.

Weitere Antworten (0)

Kategorien

Mehr zu Numeric Types 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!

Translated by