Interpolation of an array of values

3 views (last 30 days)
Pranjal Pathak
Pranjal Pathak on 5 Nov 2013
Commented: G A on 13 Nov 2013
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 Comments
Jan
Jan on 5 Nov 2013
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 on 6 Nov 2013
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!

Sign in to comment.

Accepted Answer

G A
G A on 6 Nov 2013
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 Comments
Pranjal Pathak
Pranjal Pathak on 12 Nov 2013
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 on 13 Nov 2013
If dim1=dim2, then interpolation step size, as I understand your question, is the same in both directions. Or do you mean something else?

Sign in to comment.

More Answers (0)

Categories

Find more on Resizing and Reshaping Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!