How do I plot a random number of rectangles using rectangle('Position', [x y w h])?
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
Azzi Abdelmalek
on 26 Feb 2013
what is the value of b?
Azzi Abdelmalek
on 26 Feb 2013
Unless b is very big, there is no problem in your code
Karokh Ibrahim
on 26 Feb 2013
José-Luis
on 26 Feb 2013
How are you using it then? If you don't know how to manipulate b that is.
Accepted Answer
More Answers (0)
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!