matlabgraphplot

How do I add a 2D Plot along with a surface or mesh plot in MATLAB?


I would like to have a 2D plot along with a 3D surface or mesh plot - shown by the blue line I drew on the surface plot below. How do I get it?

Surface Plot

UPDATE: Natan's Solution worked :-) But I now have a new Problem - How do I add 2 Y axis to my MATLAB Plot?


Solution

  • Just add to the surf plot another plot using plot3 where the relevant axis has the limits of the surf plot.

    For example:

    z=peaks(100);
    surface(z, 'EdgeColor', 'none');
    colormap(hot)
    view(30,30); camlight; axis vis3d
    
    x1=linspace(0,100);
    hold on
    plot3(x1,0*ones(1,numel(x1)),4*sin(x1))
    

    enter image description here