MATLAB: How to make the wave in the negative part disappear

for loopif statementwhile loop

t= linspace(0,6,100);
y=sin(pi*t);
plot(t,y)

Best Answer

More resolution for the values + logical indexing:
t= linspace(0,6,5000);
y=sin(pi*t);
plot(t(y>=0),y(y>=0))
Related Question