Filter löschen
Filter löschen

Object movement, 2D environment

4 Ansichten (letzte 30 Tage)
DAT VUONG
DAT VUONG am 30 Mai 2018
Beantwortet: Geoff Hayes am 31 Mai 2018
I want to do following tasks: 1. create two square objects 2. Two objects move 2D environment.
Thanks a lot
  5 Kommentare
Jan
Jan am 30 Mai 2018
@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 am 31 Mai 2018
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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Geoff Hayes
Geoff Hayes am 31 Mai 2018
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).

Kategorien

Mehr zu Labels and Annotations finden Sie in Help Center und File Exchange

Produkte


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by