how to divide a rectangle into 5 equal parts???
1 view (last 30 days)
Show older comments
i have defined a rectangle using this command
rectangle('Position',[800,900,500,1000]);
- How can i divide the rectangle into 5 equal parts horizontally
- Please help me sort this out thank you in advance
0 Comments
Answers (2)
Azzi Abdelmalek
on 14 Jun 2015
Edited: Azzi Abdelmalek
on 14 Jun 2015
n=5 % number of parts
h=rectangle('Position',[800,900,500,1000]);
pos=get(h,'position')
a=pos(3)/n
for k=1:n
hold on
new_pos=k*a
rectangle('Position',[pos(1:2) new_pos pos(4)]);
end
hold off
4 Comments
Jan
on 14 Jun 2015
Edited: Jan
on 18 Jun 2015
@Arjun: Your questions are welcome in this forum without any doubts. Of course this forum is based on questions.
But there are different kinds of answers: One type solves the problem as fast as possible, the other tries to assist you to solve the problem by your own. The later has the advantage, that you learn to solve other problems by your own in the future.
The readers can assume that you did try to solve your question by your own already. And in the majority of cases these trials are very good and match the exact question quite well. Only some typos or misunderstandings cause errors. Then posting a completely new answer will not be as useful as asking you to post, what you have tried so far and help you to fix the error.
Therefore a good question contains the required details and usually the relevant part of the code which has been created so far. See http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer.
Especially for homework questions posting complete solutions is a serious problem, because some students copy the solutions and this is cheating. I do not think, that you want to cheat. I'm convinced that your question is serious and that Azzi is eager to solve your problem. But some other users try to misuse the forum as cheap solver and do not care about showing any own effort. And I think you could learn more, if you are assisted to solve the problem by your own. See http://www.mathworks.com/matlabcentral/answers/8626-how-do-i-get-help-on-homework-questions-on-matlab-answers .
Please accept Azzis answer if it solves your problem.
@Azzi: Okay. Thanks for your reply. I will stop to ask you repeatedly.
Jan
on 14 Jun 2015
Edited: Jan
on 14 Jun 2015
This creates 5 rectangles with the same dimensions:
rectangle('Position', [ 800,900,100,1000])
rectangle('Position', [ 900,900,100,1000])
rectangle('Position', [1000,900,100,1000])
rectangle('Position', [1100,900,100,1000])
rectangle('Position', [1200,900,100,1000])
0 Comments
See Also
Categories
Find more on Computer Vision with Simulink 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!