Interpolation of an array of values

2 vues (au cours des 30 derniers jours)
Pranjal Pathak
Pranjal Pathak le 5 Nov 2013
Commenté : G A le 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 commentaires
Jan
Jan le 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 le 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!

Connectez-vous pour commenter.

Réponse acceptée

G A
G A le 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 commentaires
Pranjal Pathak
Pranjal Pathak le 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 le 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?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Interpolation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by