plot with if else command

조회 수: 4 (최근 30일)
Yingnan Huo
Yingnan Huo 2019년 3월 6일
댓글: Yingnan Huo 2019년 3월 6일
c=[1 -12 24 -48]
croots=roots(c)
Use the if - elseif construct to plot the 1st root as follows: if
the root is less than 3 or greater than 5, plot the root as red + with
size 32; if the root is greater than 3 and less than 5, plot the root
as a blue square size 32.
  댓글 수: 1
madhan ravi
madhan ravi 2019년 3월 6일
Please show what you have tried for your homework.

댓글을 달려면 로그인하십시오.

채택된 답변

KSSV
KSSV 2019년 3월 6일
Check the demo example.
figure
hold on
for i = 1:10
x = rand ;
if x < 0.5
plot(i,x,'*r')
else
plot(i,x,'*b')
end
end

추가 답변 (0개)

카테고리

Help CenterFile 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!

Translated by