Is it possible to take a cross section at different points of a 3-D plot?
11 views (last 30 days)
Show older comments
I have a script which when ran produces various 3 dimensional plots, I was wondering if there is any way to obtain a 2 dimensional plot for a given point along any of the axis?
Many thanks
C Boyce
0 Comments
Accepted Answer
Star Strider
on 10 Apr 2015
If you want to see them parallel to the x or y axes it’s easy enough:
x = linspace(-2, 2, 25);
y = linspace(-pi, pi, 25);
[X,Y] = meshgrid(x,y);
Z = X.^2 + sin(Y);
figure(1)
surf(X, Y, Z)
grid on
iy = Y(X == 1);
iz = Z(X == 1);
figure(2)
plot(iy, iz)
grid on
title('Plot Z(Y,X=1)')
ix = X(Y == 3*pi/4);
iz = Z(Y == 3*pi/4);
figure(3)
plot(ix, iz)
grid on
title('Plot Z(X,Y=3*\pi/4)')
To see them at a particular value of z, use the contour function. To see them in any other orientation, use the slice function.
2 Comments
Star Strider
on 13 Apr 2015
No worries! We all have lives outside MATLAB Answers.
Thank you. My pleasure.
More Answers (0)
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!