How can I project a 3-D surface onto an axis?

11 views (last 30 days)
I would like to generate a projection of a surface on one axis. For example, I wish to see the x-z axis of a 3-D view of a surface. What MATLAB commands allow me to do this?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This bug has been fixed in Release 14 Service Pack 2 (R14SP2). For previous releases, please read below for any possible workarounds:
[X,Y] = meshgrid([-2:.2:2]);
Z = X.*exp(-X.^2-Y.^2);
surf(X,Y,Z,gradient(Z)) % An example of 3D plot
colorbar
xlabel('X-AXIS')
ylabel('Y-AXIS')
zlabel('Z-AXIS')
axis([-2 2 -2 3 -0.5 0.5]) % Increasing the Ymax value in the axis to 3.
SX=size(X);
Y3 = 3*ones(SX); % A projection along Y-axis by making all Y-values to 3.
hold on
surf(X,Y3,Z,gradient(Z))

More Answers (0)

Community Treasure Hunt

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

Start Hunting!