Interpolate timeseries of a 4D matrix (4th D as time)
53 次查看(过去 30 天)
显示 更早的评论
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!