Data point missing in if statement
显示 更早的评论
The following piece of code only plots 4 points and it should plot 5 (not 6 because two points overlap). I was wondering if you could tell me how to fix it.
A = [5;5;5;3;3;2];
B = [10;4;10;10;4;4];
for n = 1:length(A)
if A(n) == 5
plot(A(n),B(n),'rx')
elseif A(n) == 3
hold on
plot(A(n),B(n),'bx')
else
hold on
plot(A(n),B(n),'gx')
end
end
axis([0 10 0 20])
Please note that I want to use if staments.
The output should be:

But the bottom red point is missing when using the code above...
1 个评论
John D'Errico
2019-4-6
编辑:John D'Errico
2019-4-6
And why exactly did you feel it necessary to post the same identical question two days in a row? Your first question got an answer. If you post it again, I will start closing the new ones. Just get someone to clarify things, rather than posting over and over again.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Graphics Performance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!