How to interpolate only on a certain direction?

5 ビュー (過去 30 日間)
Alessandro Longo
Alessandro Longo 2018 年 1 月 10 日
コメント済み: Matt J 2018 年 1 月 11 日
Hello, I have a series of matrix H of dimensions: 2x2x2049, defined for 2049 values of the frequency, from 0 to 3200 Hz. I would interpolate H so that I will have a series of matrix of dimensions 2x2x100000 for 100000 values of the frequency, from 5 to 50 Hz. How can I do this?
  2 件のコメント
Adam
Adam 2018 年 1 月 10 日
doc interp3
should work for this, provided you give it the same input and output grids for the first two dimensions.
Alessandro Longo
Alessandro Longo 2018 年 1 月 10 日
It does not work. I tried in this way:
[xx,yy,zz] = meshgrid(1:2,1:2,f_swept);
Htrue_interp = interp3(Htrue,xx,yy,zz,'spline');
where Htrue has dimension 2x2x2049 and f_swept is my long vector

サインインしてコメントする。

回答 (1 件)

Matt J
Matt J 2018 年 1 月 10 日
編集済み: Matt J 2018 年 1 月 10 日
Hr=reshape( permute(H,[3,1,2]) , [],4 ); %convert to 2D array
tmp=interp1(...,Hr,...); %interpolate the columns
Hnew= reshape( ipermute(tmp,[3,1,2]) ,[2,2,100000] ); %convert back to 3D
  3 件のコメント
Matt J
Matt J 2018 年 1 月 11 日
Yes it does...
Matt J
Matt J 2018 年 1 月 11 日
Take this H as a simpler example
H(:,:,1) =
1 1
1 1
H(:,:,2) =
2 2
2 2
H(:,:,3) =
3 3
3 3
I will upsample it by a factor 2 by interpolation:
tmp=interp1(Hr,linspace(1,3,5));
Hnew= reshape( ipermute(tmp,[3,1,2]) ,[2,2,5] );
The result:
Hnew(:,:,1) =
1 1
1 1
Hnew(:,:,2) =
1.5000 1.5000
1.5000 1.5000
Hnew(:,:,3) =
2 2
2 2
Hnew(:,:,4) =
2.5000 2.5000
2.5000 2.5000
Hnew(:,:,5) =
3 3
3 3
Is this not the kind of thing you want???

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by