Matrix interpolation in the direction of the third dimension

조회 수: 2 (최근 30일)
Ano
Ano 2019년 6월 19일
댓글: Ano 2019년 6월 28일
Hello!
I would like to perform matrix (n x n) interpolation in the direction of the third dimension which is frequency (1 x N), in a way to obtain intermediate matrices which are the interpolated ones. In my case I need to perform quadratic interpolation method which is not provided in interp1, and the use of polyfit together with polyval needs vectors while I have matrices. any ideas how can I proceed? Thank you very much!
  댓글 수: 3
Jan
Jan 2019년 6월 19일
@Ano: Please mention, what your inputs are. You can use polyfit to get the scaling factors for each matrix.
John D'Errico
John D'Errico 2019년 6월 24일
Please don't add answers just to respond to an answer. Note that multiple people have made COMMENTS. Learn to use them.

댓글을 달려면 로그인하십시오.

답변 (1개)

Gert Kruger
Gert Kruger 2019년 6월 19일
Here is my attempt at answering your question. I imagine that there are N matrices each with size nxn.
Example matrices:
%%
n = 10; %Matrix size
N = 5; %Number of matrices
%% Generate example matrices
for count = 1:N
CM{count} = rand(n) ; %CM Cell array matrices
end
Then we fit quadratic functions along the third dimension.
%% Generate fits along the third dimension
temp_ar = zeros(1, N);
for x = 1:n
for y = 1:n
for z = 1:N
temp_ar(z) = CM{z}(x, y);
end
Cfit{x, y} = fit( (1:N)', temp_ar', 'poly2');
end
end
Interpolation is achieved by evaluating the fitted functions:
%% Output matrix generation
%For example output matrix, A, must be 'halfway' between 2nd and 3rd input matrices
A = zeros(n);
z = 2.5; %Evaluation depth
for x = 1:n
for y = 1:n
A(x, y) = Cfit{x, y}(z);
end
end
We can test the output matrix, by using the norm:
norm(CM{2} - A)
norm(CM{3} - A)
norm(CM{5} - A)
Note, that the measure of the difference for the first two is less than for the last one, because the matrix A slice is 'further away' from that depth.
  댓글 수: 3
Gert Kruger
Gert Kruger 2019년 6월 27일
Ano,
the matrices A in my proposed answer is generated from the CM matrices. In my case, when z=1, A=CM{1} and when z=2 then A=CM{2}.
I don't know what you mean by inserted. Do you instead mean that there are new matrices (sample points) which need to be sorted into the CM matrix list?
Ano
Ano 2019년 6월 28일
First, thank you very much for your reply, I am grateful for that.
yes, which means that the obtained matrix A at z= 2.5 from your example need to be added into the final version of CM, therefore if I have at the beginning CM defined for 5 frequency samples, and I computed A let say for two additional intermediate samples (i.e., z= 2.5, and z =3.5) my final CM must be defined for 7 samples including the newly interpolated values represented by matrix A. Any suggestions?!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by