Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How to interpolate a sparsely spaced matrix to more fine spaced matrix

1 回表示 (過去 30 日間)
Lawrence Lechuga
Lawrence Lechuga 2018 年 4 月 25 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I have two matrices. One that represents measured values, called meas_data (21x66) and one that represents calculated data, called calc_data (201 x 651). The measured data is taking measurements over the same space, but samples way less frequently (-100 to 100 in increments of 10 in one direction and -325 to 325 in increments of 10 in the other). I want to interpolate a matrix such that the measured data can be compared element wise with the calculated matrix. meaning, I want my measured matrix to interpolate to a matrix that samples at the same spacing as the calculated matrix.
How would I go about doing so? interp2 was my first thought.
  3 件のコメント
Lawrence Lechuga
Lawrence Lechuga 2018 年 4 月 25 日

That I did. Im not sure what I am misunderstanding. I first defined a mesh grid, then defined the destination size. It throws an error saying "Input grid is not a valid MESHGRID."

[X,Y] = meshgrid(-100:10:100,-325:10:325);
X = X'; Y = Y';
[Xq, Yq] = meshgrid(-100:100,-325:325);
Xq = Xq'; Yq = Yq';
new = interp2(X, Y, meas_data,Xq, Yq);
Stephen23
Stephen23 2018 年 4 月 25 日
編集済み: Stephen23 2018 年 4 月 25 日

Do NOT transpose the X and Y matrices.

回答 (1 件)

Ameer Hamza
Ameer Hamza 2018 年 4 月 25 日
From your code in the comment, the problem is happening because you are transposing the matrics X, Y, Xq and Yq. The documentation on interp2 specifies that X, Y, need to have the same dimension as meas_data. Just remove these transpose operations from your code
[X,Y] = meshgrid(-100:10:100,-325:10:325);
[Xq, Yq] = meshgrid(-100:100,-325:325);
new = interp2(X, Y, meas_data,Xq, Yq);

Community Treasure Hunt

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

Start Hunting!

Translated by