How do I plot a random number of rectangles using rectangle('Position', [x y w h])?
5 views (last 30 days)
Show older comments
This is how I have tried. But it does not seem to work. As fast as I run the function, MATLAB gets in Busy-mode and never returns. What am I doing wrong?
function amount = draw_rectangle(b)
amount = b;
for j =1:b;
x = rand(1)*10;
y = rand(1)*10;
w = rand(1)*10;
h = rand(1)*10;
rectangle('Position', [x y w h])
hold on;
end
end
4 Comments
Accepted Answer
Azzi Abdelmalek
on 26 Feb 2013
Edited: Azzi Abdelmalek
on 26 Feb 2013
close
hold on;
for k=1:randi(100);
rectangle('Position', 10*rand(1,4))
end
hold off
0 Comments
More Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices 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!