Why will this script not plot data in the figure? Is there a setting I'm missing? Every time I run the script, all I get is a completely blank (white) graph in the figure.
1 次查看(过去 30 天)
显示 更早的评论
clear
clf
x=rand;
y=rand;
plot(x,y)
hold on
for it=1:10000
choic=round(rand*2);
if choic ==0
x=x/2;
y=y/2;
elseif choic == 1
x = (x+1)/2;
y=y/2;
else
x=(x+0.5)/2;
y=(y+1)/2;
end
plot(x,y)
hold on
end
5 个评论
采纳的回答
Greg
2017-10-25
编辑:Greg
2017-10-25
The default behavior of plot does not include a marker. This means all you can see is the interpolated line connecting each PAIR of points. When you plot scalar x and y, there's no second point to draw a line to.
Try:
plot(x,y,'.');
To use a dot marker. Search documentation for other marker options if you don't like the dot.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!