Interpolate timeseries of a 4D matrix (4th D as time)
52 ビュー (過去 30 日間)
古いコメントを表示
Luís Henrique Bordin
2024 年 11 月 6 日 16:48
コメント済み: Luís Henrique Bordin
2024 年 11 月 6 日 18:41
Hey experts, please could you help me to figure this out?
I am trying to interpolate a 4D matrix, in which the 4th dimension is time. It has 12 records (monthly), but I want it each 3 days, so it'll be 121 records).
For this I am trying both ways below:
load data.mat
dtStr = ["15/01/2016","15/02/2016","15/03/2016","15/04/2016","15/05/2016","15/06/2016",...
"15/07/2016","15/08/2016","15/09/2016","15/10/2016","15/11/2016","15/12/2016"];
dtvA=datevec(dtStr,'dd/mm/yyyy');
dttA = datetime(dtvA);
timeS = datestr((time/86400)+datenum(1958,1,1));
dttB = datetime(timeS);
tmtb = timetable(dttA,Nit2);
NO3_clim_3daily = retime(tmtb,'regular','linear','TimeStep',days(3));
% Or
NO3_clim_3daily = retime(tmtb,dttB,'linear');
But it give me the error: "Error using timetable/retime (line 140). Interpolation requires at least two sample points in each dimension".
Why am I getting this error, if I have a matrix of 31x11x37x12?
I still could not figure it out and how to solve it. Please, could someone help me?
Thanks!
0 件のコメント
採用された回答
Stephen23
2024 年 11 月 6 日 17:10
編集済み: Stephen23
2024 年 11 月 6 日 17:21
Avoid using deprecated DATENUM & DATESTR, using DATETIME is much better.
S = load('data.mat')
dttA = datetime(2016,1:12,15);
dttB = datetime(S.time(:),'convertfrom','epochtime','Epoch',datetime(1958,1,1));
"Why am I getting this error, if I have a matrix of 31x11x37x12?"
Note that for a TIMETABLE the first dimension (i.e. rows) must correspond to the time: in contrast the 4th dimension of your array has size 12, thus seems to correspond to the 12 months you specified. So we would need to permute that array so that it fits the TIMETABLE definition:
tmtb = timetable(dttA(:),permute(S.Nit2,[4,1,2,3]))
after that RETIME is exactly as you showed:
NO3_clim_3daily = retime(tmtb,'regular','linear','TimeStep',days(3))
NO3_clim_3daily = retime(tmtb,dttB)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Time Series Events についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!