Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Animate plot

Subject: Animate plot

From: Ben

Date: 22 Mar, 2009 23:08:01

Message: 1 of 2

Hi, I just want to ask how do you animate a plot in MATLAB, say i want to animate a how a six- bar mechanism moves/rotates. I have plotted a graph of my mechanism with this function, now, i just want to see it move.

x1 = [0 pos_r2x pos_r3x pos_r1x];
y1 = [0 pos_r2y pos_r3y pos_r1y];

x2 = [pos_r1x pos_r4x pos_r6x pos_r1x];
y2 = [pos_r1y pos_r4y pos_r6y pos_r1y];

x3 = [pos_r1x pos_r6x pos_r7x pos_r5x];
y3 = [pos_r1y pos_r6y pos_r7y pos_r5y];

xp = [pos_r6x pos_rpx pos_r7x];
yp = [pos_r6y pos_rpy pos_r7y];


plot(x1,y1,'-bo','LineWidth',1.5,...
                'MarkerEdgeColor','r',...
                'MarkerFaceColor','r',...
                'MarkerSize',5);
hold on;
plot(x2,y2,'-bo','LineWidth',1.5,...
                'MarkerEdgeColor','r',...
                'MarkerFaceColor','r',...
                'MarkerSize',5);
hold on;
plot(x3,y3,'-bo','LineWidth',1.5,...
                'MarkerEdgeColor','r',...
                'MarkerFaceColor','r',...
                'MarkerSize',5);
hold on;
plot(xp,yp,'-bo','LineWidth',1.5,...
                'MarkerEdgeColor','r',...
                'MarkerFaceColor','r',...
                'MarkerSize',5);
            
hold off;

Any help will be appreciated. Thanks.

Subject: Animate plot

From: Darren Rowland

Date: 23 Mar, 2009 00:41:02

Message: 2 of 2

The drawnow function might help you do this. Type
doc drawnow
for an example of its usage.
Hth
Darren

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us