Plot not shown in for loop
1 次查看(过去 30 天)
显示 更早的评论
The plot is not appearing for this simple loop
for i=0:0.01:1
if i<0.5
M=1
elseif i<0.7
M=0.5
else
M=0
end
plot(i,M,'LineWidth',2)
hold on
end
0 个评论
采纳的回答
Torsten
2022-3-8
iter = 0;
for i=0:0.01:1
iter = iter + 1;
I(iter) = i;
if i<0.5
M(iter)=1
elseif i<0.7
M(iter)=0.5
else
M(iter)=0
end
end
plot(I,M,'LineWidth',2)
0 个评论
更多回答(1 个)
Jan
2022-3-8
Exactly. Give Matlab a chance to update the output by inserting the command:
drawnow
inside the loop.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Performance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!