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.
2 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Greg
on 25 Oct 2017
Edited: Greg
on 25 Oct 2017
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 Comments
More Answers (0)
See Also
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!