Confusion with interp3 and interpn
Afficher commentaires plus anciens
Hi,
According to my teacher, "for a matrix indexed as [M, N, P], the axis variables must be given in the order N, M, P" in relation to the swaping of variables at the interp3 line:
[X, Y, Z] = size(data);
ts= [20 30 20]
[x, y, z] = ndgrid((1:X)/X, (1:Y)/Y, (1:Z)/Z);
[x2, y2, z2] = ndgrid((1:ts(1))/(ts(1)), (1:ts(2))/(ts(2)), (1:ts(3))/(ts(3)));
test1= interp3(y, x, z, data, y2, x2, z2, 'linear');
However, I couldn't find this info on the function's page, nor it makes any sense to me (even though the computation seems correct!).
Any help welcome, thank you,
TS
5 commentaires
darova
le 24 Avr 2020
I don't understand the question. What are you asking?
Tahariet Sharon
le 26 Avr 2020
darova
le 25 Mai 2020
Did you try 'x,y,z' order? I think the result should be the same
Tahariet Sharon
le 25 Mai 2020
Modifié(e) : Tahariet Sharon
le 25 Mai 2020
darova
le 25 Mai 2020
Maybe it's the answer on your question
Réponse acceptée
Plus de réponses (1)
darova
le 25 Mai 2020
here is an example
[x,y] = meshgrid(1:5);
z = x.^2 + y.^2/2;
[x1,y1] = meshgrid(1:0.5:5);
z1 = interp2(x,y,z,x1,y1); % standart interpolation
z2 = interp2(y',x',z,y1',x1'); % interpolation y x
surf(x,y,z,'facecolor','none')
hold on
plot3(x1(:),y1(:),z1(:),'.r')
plot3(x1(:),y1(:),z2(:),'ob')
hold off
legend('original surface',...
'standard interpolation',...
'y x interpolation','location','north')
axis vis3d

2 commentaires
Tahariet Sharon
le 26 Mai 2020
Tahariet Sharon
le 26 Mai 2020
Modifié(e) : Tahariet Sharon
le 26 Mai 2020
Catégories
En savoir plus sur Graphics Performance dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
