Object movement, 2D environment

I want to do following tasks: 1. create two square objects 2. Two objects move 2D environment.
Thanks a lot

댓글 수: 5

Geoff Hayes
Geoff Hayes 2018년 5월 30일
Dat - what have you tried so far? Are you using Simulink or are you just creating/plotting two squares and then moving them according to some motion model?
Jan
Jan 2018년 5월 30일
Or do you want to move them with the mouse? Maybe you want to control a robot using Simulink to move real objects?
DAT VUONG
DAT VUONG 2018년 5월 30일
i just want to create creating two squares and moving them in my model. And save this model as a video. Then, i will process in this video.
Jan
Jan 2018년 5월 30일
@DAT VUONG: We cannot read your mind and in consequence we cannot know, what "creating two squares" exactly means. "Moving them in my model" can mean a variety of things also. At least "saving as a video" seems to imply, that you mean 2D or 3D graphics.
Please give us a chance to help you and ask much more specifically.
DAT VUONG
DAT VUONG 2018년 5월 31일
Thanks for your comment. Actually, i want to create a 2D environment where two objects with Square shape move to identified direction. How can i do that? thanks.

댓글을 달려면 로그인하십시오.

답변 (1개)

Geoff Hayes
Geoff Hayes 2018년 5월 31일

0 개 추천

Dat - one solution may be to use rectangle. You would draw the rectangle/square within an axes and then, using the handle to the rectangle object, change its position to "move" the square. For example,
f = figure;
axis([-100 100 -100 100])
mySquare = rectangle('Parent',gca, 'Position',[0 0 5 5])
So this will create a rectangle whose lower left corner is at (0,0) and whose width and height is five. You can then move the square by changing its position
set(mySquare,'Position',[1 1 5 5])
You should be able to extend this to two (or more squares) and move them around your 2D environment (defined by the axes dimensions).

카테고리

도움말 센터File Exchange에서 Labels and Annotations에 대해 자세히 알아보기

제품

릴리스

R2017b

태그

질문:

2018년 5월 30일

답변:

2018년 5월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by