How to add differentiate a point on my graph using a for loop
이전 댓글 표시
Iam trying to have points in CG_X turned into a red color when its less than -15 or greater than 15 when I plot it on the graph using a for loop, but the end result gives me the standard blue color which is want i want when CG_X is greater than or equal to -15 and less than or equal to 15.
CG_X=[13.8 18 18.8 -5.7 2.2 -11.1 -6.3 12.4 -10.5 15.6];
CG_Y=[4.2 -13.2 -8 -11.3 11.2 1.5 -5.0 8 -7.1 19.7];
hold on;
for k=length(CG_X)
if k>15||k<-15
plot(CG_X,CG_Y,'r*');
elseif k
plot(CG_X,CG_Y,'b*');
end
end
hold off;
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!