Borrar filtros
Borrar filtros

how to divide a rectangle into 5 equal parts???

3 visualizaciones (últimos 30 días)
arjun ramanujam
arjun ramanujam el 14 de Jun. de 2015
Editada: Jan el 18 de Jun. de 2015
i have defined a rectangle using this command
rectangle('Position',[800,900,500,1000]);
  1. How can i divide the rectangle into 5 equal parts horizontally
  2. Please help me sort this out thank you in advance

Respuestas (2)

Azzi Abdelmalek
Azzi Abdelmalek el 14 de Jun. de 2015
Editada: Azzi Abdelmalek el 14 de Jun. de 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 comentarios
arjun ramanujam
arjun ramanujam el 14 de Jun. de 2015
Editada: arjun ramanujam el 14 de Jun. de 2015
@jan simon i am learning matlab and i did not expect such a comment when learning you also might have had doubts what if i told you this that time ,everybody has doubts and this is a common forum and i am doing my mtech project if i could i would put my whole mtech project here as a doubt which my conscience would not permit and for the kind information this is a smallest part of my project of which only matlab related doubts are being put here of which the major part will be solved by me and not put here anyways @Azzi thank you for your answer
Jan
Jan el 14 de Jun. de 2015
Editada: Jan el 18 de Jun. de 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.

Iniciar sesión para comentar.


Jan
Jan el 14 de Jun. de 2015
Editada: Jan el 14 de Jun. de 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])

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by