How do I plot a random number of rectangles using rectangle('Position', [x y w h])?
Afficher commentaires plus anciens
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 commentaires
Azzi Abdelmalek
le 26 Fév 2013
what is the value of b?
Azzi Abdelmalek
le 26 Fév 2013
Unless b is very big, there is no problem in your code
Karokh Ibrahim
le 26 Fév 2013
José-Luis
le 26 Fév 2013
How are you using it then? If you don't know how to manipulate b that is.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!