Interpolation of an array of values

4 ビュー (過去 30 日間)
Pranjal Pathak
Pranjal Pathak 2013 年 11 月 5 日
コメント済み: G A 2013 年 11 月 13 日
Hi,
I have an array of values which is not a square one(different rows have different number of elements and they are placed in such a way that the first element (i.e. 1) of second row is placed in the mid of first two elements (i.e. 3 & 5) of the first row and so on). I want to interpolate (bi-linear) this matrix into a square matrix of dimension 36x36.
A = [3 5 8 9 1 4;
1 6 9 2 5;
6 7 8 9 10 12;
2 5 1 3 4;
1 2 4 6 8 9;
3 1 4 5 8];
Can anybody please help me in doing this in Matlab.
Thanking You!
  2 件のコメント
Jan
Jan 2013 年 11 月 5 日
This is not a matrix. Matrices have the same number of elements in each row by definition. Therefore the shown definition of A is not clear. In consequence we cannot guess how your input is represented and this does not allow to guess which kind of procedure you are looking for.
Please edit the question and show us, how your input matrix A is defined in a way, Matlab does understand.
Pranjal Pathak
Pranjal Pathak 2013 年 11 月 6 日
Dear Simon, You are right,it is not a matrix. But my set of values are of this type and dimension. In this case we can assume, each of the rows as a different row matrix and interpolate each of them separately upto a diemnsion of 1x36 along horizontal direction. After that, it can be interpolated along vertical direction separately upto a dimension of 36x1. Finally concatenate them to form a square matrix of dimension 36x36. Please help me in doing this.
Thanking You!

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

採用された回答

G A
G A 2013 年 11 月 6 日
Do you mean something like this?
A = {[3 5 8 9 1 4];
[1 6 9 2 5];
[6 7 8 9 10 12];
[2 5 1 3 4];
[1 2 4 6 8 9];
[3 1 4 5 8]};
dim1=36;
dim2=36;
B=zeros(length(A),dim2);
for k=1:length(A)
x1=1:length(A{k});
x2=linspace(1,length(x1),dim2);
B(k,:)=interp1(x1,A{k},x2,'linear');
end
x3=1:length(A);
x4=linspace(1,length(x3),dim1);
C=zeros(dim1,dim2);
for k=1:dim2
C(:,k)=interp1(x3,B(:,k),x4,'linear');
end
  4 件のコメント
Pranjal Pathak
Pranjal Pathak 2013 年 11 月 12 日
Dear GA,
I have a query. If we want to make our step size of interpolation equal in both the horizontal and vertical directions, then how to do this?
Thanking You!
G A
G A 2013 年 11 月 13 日
If dim1=dim2, then interpolation step size, as I understand your question, is the same in both directions. Or do you mean something else?

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by