Interpolation of an array of values

4 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by