Choosing the Axis for Interp2?

3 visualizaciones (últimos 30 días)
Shelton Ware
Shelton Ware el 26 de Mayo de 2022
Respondida: Star Strider el 26 de Mayo de 2022
I do not understand why I cannot switch the axis that the interp2 function runs on?
As you can see with the code below I am attempting to get a cross section in the "X-Z" plane instead of the "Y-Z" as shown in the first block.
X=-1:0.1:1;
Y=-1:0.1:1;
Z=membrane(1,10,10);
figure(1)
surf(X,Y,Z);
x=-0.5;
z=interp2(X,Y,Z,x,Y);
figure(2)
plot(Y,z);
y=-0.5;
z1=interp2(X,Y,Z,y,X);
figure(3)
plot(X,z1)

Respuesta aceptada

Star Strider
Star Strider el 26 de Mayo de 2022
Use plot3 instread of plot, since the plot is in three dimensions —
X=-1:0.1:1;
Y=-1:0.1:1;
Z=membrane(1,10,10);
figure(1)
surf(X,Y,Z);
xlabel('X')
ylabel('Y')
x=-0.5;
z=interp2(X,Y,Z,x,Y);
figure(2)
surf(X,Y,Z)
hold on
plot3(ones(size(X))*x,Y,z, '-r', 'LineWidth',3);
hold off
xlabel('X')
ylabel('Y')
y=-0.5;
z1=interp2(X,Y,Z,X,y);
figure(3)
surf(X,Y,Z)
hold on
plot3(X,ones(size(Y))*y,z1, '-r', 'LineWidth',3);
hold off
grid on
xlabel('X')
ylabel('Y')
.

Más respuestas (0)

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by