Azzera filtri
Azzera filtri

How to make space underneath the lines white opaque in 3D plot?

4 visualizzazioni (ultimi 30 giorni)
I need to fill below the lines in opaque white so that it does not show lines behind. I tried to use the surf command but it does not work.
Here is my code until now:
[xn,yn] = meshgrid(linspace(0,0.5,14),linspace(-15,15,100));
zn = exp(-2*yn.^2).*xn;
xn = xn(:);
yn = yn(:);
zn = zn(:);
%%%%%%%%%%%%%%%%%%%%
index = find(diff(yn)<0);
zn(index) = nan;
%%%%%%%%%%%%%%%%%%%%%
len = index(1);
index = [0;index]+1;
index = index(1:2:end); % every 3rd line -- change to select how many lines to plot
elems = ((0:len) + index).'; % implicit singleton expansion
elems = elems(:);
xn = xn(elems);
yn = yn(elems);
zn = zn(elems);
plot3(xn,yn,zn)
set(gca,'ylim',[-10,10],'zlim',[0,2]);
box off
campos([-2.3393; -134.9790; -2.2455])

Risposta accettata

Star Strider
Star Strider il 21 Lug 2018
A relatively simple way is to use the patch function:
[xn,yn] = meshgrid(linspace(0,0.5,14),linspace(-15,15,100));
zn = exp(-2*yn.^2).*xn;
figure
patch(xn,yn,zn,'w', 'EdgeColor','none')
hold on
plot3(xn,yn,zn,'b')
hold off
set(gca,'ylim',[-10,10],'zlim',[0,2]);
box off
campos([-2.3393; -134.9790; -2.2455])
view(45,15)

Più risposte (0)

Tag

Prodotti


Release

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by