当您想根据pandas重采样功能的时间戳重新采样python中的数据时,它很容易使用。例如,从数据帧1开始,时间戳以秒为单位,另一个重新采样,平均为10分钟。
df1_10m=df1.resample('10T', how='mean')
现在我需要在matlab中做同样的事情,但我找不到明确的方法。
函数resample似乎是另一回事。
我尝试重塑,但是我遇到了错误。
function[Data_10mean]=resamp(table)
table.ts=datestr(table.ts); % format the time stamp
TableArray=table2array(table)
j=1;
for i=1:13
temp=TableArray(:,i);
table_r=reshape(temp,600,[]);
table_rmean=mean(table_r,'omitnan');
Size=size(table_rmean);
temp_index=Size(2);
Data_temp=reshape(table_rmean,temp_index,1);
Data_10mean(:,j)=Data_temp(:,1);
j=j+1; %counter for the columns of each iteration
end
end
Error using reshape
Product of known dimensions, 600, not divisible into total number of elements, 13526.
如果我寻求帮助是因为我真的需要它。我熟悉python而不太熟悉matlab。在python中这么简单似乎没有在matlab中有特定的功能。
答案 0 :(得分:1)
您可以在 matlab 中使用函数 retime :
<块引用>retime:重新采样或聚合时间表中的数据,并解决重复或不规则的时间
TT2 = retime(TT1,newTimeStep,method)
它在方法中有一个 mean
函数。