how to divide a rectangle into 5 equal parts???
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (2 件)
Azzi Abdelmalek
2015 年 6 月 14 日
編集済み: Azzi Abdelmalek
2015 年 6 月 14 日
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 件のコメント
Jan
2015 年 6 月 14 日
編集済み: Jan
2015 年 6 月 18 日
@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
2015 年 6 月 14 日
編集済み: Jan
2015 年 6 月 14 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Computer Vision with Simulink についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!