Spline interpolation of 4D matrix

Hello everyone,
I have a 4D matrix A of size 450x450x60x3. This matrix corresponds to images measured at different power levels, B. Where each pixel in A was measured with a different powerlevel. So I have a another matrix B of size 450x450x60x3. I want to perform a spline interpolation of A for power level [1.3, 1.7, 2.3]. What would be the best way to do this? Should I be treating this problem as a 3 times 1D interpolation or do I need to use gridded data? If so, how can I do this?
Thank you :)

Antworten (1)

KSSV
KSSV am 18 Aug. 2022

0 Stimmen

A = rand(450,450,50,3) ;
B = zeros(size(A)) ;
for i = 1:450
for j = 1:450
for k = 1:50
B(i,j,k,:) = interp1([1 2 3],squeeze(A(i,j,k,:)),[1.3 1.7 2.3]) ;
end
end
end

3 Kommentare

MM
MM am 18 Aug. 2022
Bearbeitet: MM am 18 Aug. 2022
Thanks a lot KSSV. I forgot to mention in my question that actually each element A has a different value for B. So instead of a vector ([1 2 3]), I have a another 4D matrix, let's call it B1. So it would be:
for i = 1:450
for j = 1:450
for k = 1:50
B(i,j,k,:) = interp1(squeeze(B1(i,j,k,:)),squeeze(A(i,j,k,:)),[1.3 1.7 2.3]) ;
end
end
end
But this gives me an error
Error using griddedInterpolant
Interpolation requires at least two sample points in each dimension.
Error in interp1 (line 134)
F = griddedInterpolant(X,V(:,1),method);
KSSV
KSSV am 18 Aug. 2022
What is B1??? It seems in B1 the values are not in increasing order....they are supposed to be monotonically increasing.
MM
MM am 18 Aug. 2022
See attached for an example of B1. I only included B1(:,:,1:3,:) instead of all 50 for the 3rd dimension because otherwise it was too big.
Let me give a little bit more explanation on the data.
For the measurement of the data in A, I used B1 = [1.3, 1.7,2.3]. But the real value used by the machine is spatially dependent and so B1 is different for each x,y which is represented in the attached matrix. B1 is the same in the 3rd dimension.
I want to determine what the values in A would be if B1 was [1.3, 1.7, 2.3] for each x,y. So I want to interpolate the data in A for B1 = 1.3, 1.7 and 2.3.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Interpolation finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2019a

Gefragt:

MM
am 18 Aug. 2022

Kommentiert:

MM
am 18 Aug. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by