Interpolate data in array to match specified length of data in another vector.
33 ビュー (過去 30 日間)
古いコメントを表示
I have a matrix (A) of data recorded at 100Hz and another matrix (B) recorded at 2000Hz over the same period of time. The data is synchronised so start and end time points match. How can I upsample the data in matrix A to match the length of the data in matrix B? I understand interp1 is the tool to use but am unsure how to implement this.
I tried something like this, but ended up with NaNs in A_new after the length of A;
Here, A is a 1267 x 3 and B is a 52820 x 1.
for i = 1:3
x1 = 1:1:size(A(:,i))
v1 = (A(:,i))'
xq1 = 1:1:size(B,1) %Define num of points for finer sampling range over x.
A_new(:,i) = (interp1(x1,v1,xq1))'; %Interpolate the function at the query points.
end
Thanks.
0 件のコメント
採用された回答
KSSV
2021 年 3 月 26 日
m = size(A,1) ; % m = 1267
n = size(B,1) ; % n = 52820
A_new = zeros(n,3) ;
xi = (1:n)' ;
x = linspace(1,n,m)' ;
for i = 1:3
Ai = interp1(x,A(:,i),xi) ;
A_new(:,i) = Ai ;
end
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Multirate Signal Processing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!