[Solved] Upsampling multidimensional array with interpn

10 ビュー (過去 30 日間)
Johnny Scalera
Johnny Scalera 2020 年 7 月 9 日
編集済み: Johnny Scalera 2020 年 7 月 10 日
Hi all,
I'm trying to upsample a multidimensional array. Here is the code that I used for a monodimensional array:
sf1 = 100; %original sampling frequency
time = (0:(1/sf1):10-(1/sf1))'; %time array
x = randn(length(time), 1);
sf2 = 200; %final sampling frequency
upTime = (0:(1/sf2):10-(1/sf2))';
y = interp1(time, x, upTime);
Now I would like to upsample a 5D array, such as:
z = [randn(length(time), 1) randn(length(time), 1) randn(length(time), 1) randn(length(time), 1) randn(length(time), 1)];
How Can I use the interpn function properly?
Thank You all!

採用された回答

John D'Errico
John D'Errico 2020 年 7 月 9 日
編集済み: John D'Errico 2020 年 7 月 9 日
That is NOT a 5 dimensional array.
While you may THINK of it as a set of points that live in 5 dimensions, it is NOT a 5-d array. You CANNOT use interpn to interpolate that data. NOT. Period. NOT.
THIS is a 5-dimensional array:
A = rand(2,3,4,5,6);
size(A)
ans =
2 3 4 5 6
You can then use tools like griddatan or scatteredInterpolant to interpolate such data.
If you want to view the data as 5 independent streams of ONE dimensional data, then you can still use interp1 to interpolate. For example:
A = rand(100,5);
t = (1:100)';
interp1(t,A,7.25)
ans =
0.35284 0.051081 0.32818 0.34913 0.75639
Only you know what the array represents. By themselves, numbers are just numbers. Only you know what they represent.
  2 件のコメント
Johnny Scalera
Johnny Scalera 2020 年 7 月 10 日
編集済み: Johnny Scalera 2020 年 7 月 10 日
You are right! This is the correct solution
y1 = interp1(time, z, upTime);
Thank you!
John D'Errico
John D'Errico 2020 年 7 月 10 日
Excellent. It almost had to be one of those two cases.

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

その他の回答 (0 件)

カテゴリ

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