Choosing the Axis for Interp2?

24 Ansichten (letzte 30 Tage)
Shelton Ware
Shelton Ware am 26 Mai 2022
Beantwortet: Star Strider am 26 Mai 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)

Akzeptierte Antwort

Star Strider
Star Strider am 26 Mai 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')
.

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Object Properties finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by