필터 지우기
필터 지우기

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 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