필터 지우기
필터 지우기

interpulation of 2 axes in 3D matrix

조회 수: 3 (최근 30일)
Keren Grinberg
Keren Grinberg 2022년 4월 6일
답변: Stephen23 2022년 4월 6일
i have 3D L matrix:
L(:,:,1)=
1 3 5
7 9 11
13 15 17
L(:,:,2)=
3 5 7
9 11 13
15 17 19
i want to interpulate L but only in 2 axes, the wanted solution:
L(:,:,1)=
1 2 3 4 5
7 8 9 10 11
13 14 15 16 17
L(:,:,2)=
2 3 4 5 6
8 9 10 11 12
14 15 16 17 18
L(:,:,3)=
3 4 5 6 7
9 10 11 12 13
15 16 17 18 19
from L(3x3x2) to L(3x5x3).
i tried to use interpn but i got interpulation in x axes as well.
LL=interp(L,1)
LL(:,:,1)=
1 2 3 4 5
4 5 6 7 8
7 8 9 10 11
10 11 12 13 14
13 14 15 16 17
LL(:,:,2)=
2 3 4 5 6
5 6 7 8 9
8 9 10 11 12
11 12 13 14 15
14 15 16 17 18
LL(:,:,3)=
3 4 5 6 7
6 7 8 9 10
9 10 11 12 13
12 13 14 15 16
15 16 17 18 19

답변 (1개)

Stephen23
Stephen23 2022년 4월 6일
format compact
L = cat(3,[1,3,5;7,9,11;13,15,17],[3,5,7;9,11,13;15,17,19])
L =
L(:,:,1) = 1 3 5 7 9 11 13 15 17 L(:,:,2) = 3 5 7 9 11 13 15 17 19
Xi = 1:3;
Yi = [1,3,5];
Zi = [1,3];
[Xq,Yq,Zq] = ndgrid(1:3,1:5,1:3);
A = interpn(Xi,Yi,Zi,L,Xq,Yq,Zq)
A =
A(:,:,1) = 1 2 3 4 5 7 8 9 10 11 13 14 15 16 17 A(:,:,2) = 2 3 4 5 6 8 9 10 11 12 14 15 16 17 18 A(:,:,3) = 3 4 5 6 7 9 10 11 12 13 15 16 17 18 19

카테고리

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