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:
Animation Repeats*3, why?

Subject: Animation Repeats*3, why?

From: Chris

Date: 1 Mar, 2009 17:45:03

Message: 1 of 4

Hi, I have just created my first animation, and for some reason it repeats three times. 1st at a medium speed, second very quickly and third quite slowly.
I can't find the part of my code which is causing this. Any help would be greatly appreciated.

Cheers,
Chris
-----------------------------------------------------------------------------------------------------------------
%code below
tfinal=3e6;
posvel0=[x;y;Vx;Vy]; %Hyperbolic fly by starting position
options=odeset('RelTol',1e-8);
[t,posvel]=ode45('probeeqnsefb',[0, tfinal], posvel0, options);

xe=RE*cos(q); %Earth
ye=RE*sin(q);
xm=rho0*cos(q); %Moons Orbit
ym=rho0*sin(q);

for i=1:length(posvel);
    pos=1:i;
    if i==1
        plot(posvel(pos,1),posvel(pos,2),xe,ye,xm,ym)
        axis([-16e8 5e8 -11e8 10e8],'equal')
        xlabel('Distance in x-direction (m)');
        ylabel('Distance in y-direction (m)');
        title('First Animation');
        legend('Hyp Xfer','Earth','Moon''s Orbit',...
            'location','southwest');
        hold on
    else
        plot(posvel(pos,1),posvel(pos,2))
        hold on
    end
    m(i)=getframe;
end
movie(m,1)

Subject: Animation Repeats*3, why?

From: Bruno Luong

Date: 1 Mar, 2009 18:05:03

Message: 2 of 4

"Chris " <chris.crawshaw@gmail.com> wrote in message <goehiv$lqb$1@fred.mathworks.com>...
> Hi, I have just created my first animation, and for some reason it repeats three times. 1st at a medium speed, second very quickly and third quite slowly.
> I can't find the part of my code which is causing this. Any help would be greatly appreciated.
>
> Cheers,
> Chris
> -----------------------------------------------------------------------------------------------------------------
> %code below
> tfinal=3e6;
> posvel0=[x;y;Vx;Vy]; %Hyperbolic fly by starting position
> options=odeset('RelTol',1e-8);
> [t,posvel]=ode45('probeeqnsefb',[0, tfinal], posvel0, options);
>
> xe=RE*cos(q); %Earth
> ye=RE*sin(q);
> xm=rho0*cos(q); %Moons Orbit
> ym=rho0*sin(q);
>
> for i=1:length(posvel);
> pos=1:i;
> if i==1
> plot(posvel(pos,1),posvel(pos,2),xe,ye,xm,ym)
> axis([-16e8 5e8 -11e8 10e8],'equal')
> xlabel('Distance in x-direction (m)');
> ylabel('Distance in y-direction (m)');
> title('First Animation');
> legend('Hyp Xfer','Earth','Moon''s Orbit',...
> 'location','southwest');
> hold on
> else
> plot(posvel(pos,1),posvel(pos,2))
> hold on
> end
> m(i)=getframe;
> end
> movie(m,1)

This repeat behavior in MOVIE exhibits in some older Matlab version. I believe it was corrected since.

Bruno

Subject: Animation Repeats*3, why?

From: Chris

Date: 1 Mar, 2009 18:23:01

Message: 3 of 4

I'm using 7.1 (R14) SP 3.

Is there any work around for this or to truncate the animation after the first run through?

Cheers,
Chris

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <goeiof$7j8$1@fred.mathworks.com>...
> "Chris " <chris.crawshaw@gmail.com> wrote in message <goehiv$lqb$1@fred.mathworks.com>...
> > Hi, I have just created my first animation, and for some reason it repeats three times. 1st at a medium speed, second very quickly and third quite slowly.
> > I can't find the part of my code which is causing this. Any help would be greatly appreciated.
> >
> > Cheers,
> > Chris
> > -----------------------------------------------------------------------------------------------------------------
> > %code below
> > tfinal=3e6;
> > posvel0=[x;y;Vx;Vy]; %Hyperbolic fly by starting position
> > options=odeset('RelTol',1e-8);
> > [t,posvel]=ode45('probeeqnsefb',[0, tfinal], posvel0, options);
> >
> > xe=RE*cos(q); %Earth
> > ye=RE*sin(q);
> > xm=rho0*cos(q); %Moons Orbit
> > ym=rho0*sin(q);
> >
> > for i=1:length(posvel);
> > pos=1:i;
> > if i==1
> > plot(posvel(pos,1),posvel(pos,2),xe,ye,xm,ym)
> > axis([-16e8 5e8 -11e8 10e8],'equal')
> > xlabel('Distance in x-direction (m)');
> > ylabel('Distance in y-direction (m)');
> > title('First Animation');
> > legend('Hyp Xfer','Earth','Moon''s Orbit',...
> > 'location','southwest');
> > hold on
> > else
> > plot(posvel(pos,1),posvel(pos,2))
> > hold on
> > end
> > m(i)=getframe;
> > end
> > movie(m,1)
>
> This repeat behavior in MOVIE exhibits in some older Matlab version. I believe it was corrected since.
>
> Bruno

Subject: Animation Repeats*3, why?

From: Bruno Luong

Date: 1 Mar, 2009 19:20:17

Message: 4 of 4

"Chris " <c.j.crawshaw@googlemail.com> wrote in message <goejq5$gae$1@fred.mathworks.com>...
> I'm using 7.1 (R14) SP 3.
>
> Is there any work around for this or to truncate the animation after the first run through?
>
> Cheers,
> Chris
>
A workaround is described here:
http://www.mathworks.com/support/solutions/data/1-16FM0.html?solution=1-16FM0

Bruno

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