Fill data with NaN
2 ビュー (過去 30 日間)
古いコメントを表示
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.
0 件のコメント
採用された回答
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Numeric Types についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!