How to make plot from if statement?
이전 댓글 표시
% Hi I am really stuck and would very much appreciate help!
% I want to make a graph that looks like this:

% Here is my code:
x = linspace(-5,5,50);
if (x>-2 & x<0)
Y = x*1.5+3
elseif (x>0 & x<2)
Y = x*(-1.5) + 3
else
Y = 0
end
plot(x,Y)
% How can I plot this?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!