Fill data with NaN

1 次查看(过去 30 天)
Danilo M
Danilo M 2018-7-23
回答: Adam Danz 2018-7-23
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.

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Numeric Types 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by