How can I obtain the curved lines on the surface of 'surf' plot which generate the XY plane projections in 'surfc'?

9 views (last 30 days)
Consider the following code:
f=@(x,y) (x.^2-y.^2)./(x.^2+y.^2);
[X,Y]=meshgrid(linspace(-1,1));
Z=f(X,Y);
surfc(X,Y,Z)
How can I replace the edge lines on a surface project on the XY plane with lines that run along the 'surf' plot generated, and which when projected in the XY plane, give the lines given by 'surfc'?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 13 Jun 2019
The curved lines along the 'surf' plot can be obtained for the case above by modifying and executing the code as below
f=@(x,y) (x.^2-y.^2)./(x.^2+y.^2);
[X,Y]=meshgrid(linspace(-1,1));
Z=f(X,Y);
[M,~] = contour(X,Y,Z);
x = M(1,:);
y = M(2,:);
z = f(x,y);
figure
surf(X,Y,Z), hold on
lims = axis;
scatter3(x,y,z, 'filled', 'MarkerFaceColor', 'r'), hold off
axis(lims)

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!