Effacer les filtres
Effacer les filtres

interpulation of 2 axes in 3D matrix

3 vues (au cours des 30 derniers jours)
Keren Grinberg
Keren Grinberg le 6 Avr 2022
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

Réponses (1)

Stephen23
Stephen23 le 6 Avr 2022
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

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