Interpolating many matrices without for loop

6 ビュー (過去 30 日間)
j_solar
j_solar 2011 年 11 月 17 日
Hi everybody, well I want to interpolate a 3D matrix composed of 700x2x60 values. I want to interpolate with respect to an array of 700 values. But i want an interpolation only 1 dimension, for example
if i had:
3 1
6 2
9 3
60 times, with different values, i want to interpolate with respect to 1.5, 2.5 and 3 I would get 4.5 7.5 and 10.5, 60 times and with the values relative to each one of the 60 matrices.
So in essence its like interp1 but 60 times. And I can't manage to do it without a for loop which is time consuming. and i need to do it over 15000 times.
thank you for your answers
  5 件のコメント
Fangjun Jiang
Fangjun Jiang 2011 年 11 月 17 日
You can edit your question and apply {}Code format to make it look right. I did only the {}Code formatting part but didn't change any of your text.
Fangjun Jiang
Fangjun Jiang 2011 年 11 月 17 日
Look at all the buttons above your question text box when you post or edit your question.

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

採用された回答

Fangjun Jiang
Fangjun Jiang 2011 年 11 月 17 日
You can use reshape().
x=1:3;
y=3:3:9;
X=magic(3);
[M,N]=size(X);
Y=interp1(x,y,X(:),'linear','extrap');
Y=reshape(Y,M,N);
  5 件のコメント
Jan
Jan 2011 年 11 月 17 日
Matlab's INTERP1 is lame and there is no reason to limit the algorithm to vectors. But a linear interpolation is not complicated - roughly:
Si = Ti - floor(Ti);
Ti = floor(Ti);
Yi = Y(Ti, :) .* (1 - Si) + Y(Ti + 1, :) .* Si;
I do not understand the value of c. It is a [700x1x60] array any you use c(i) for the interpolation.
j_solar
j_solar 2011 年 11 月 18 日
Really c could be a 700x1 array, but since it is going to be the second column of final I replicate it 60 times so I can insert it in final.
Then I use only one(really it could be c(1) instead of c(i)) for the interpolation

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by