From: Eric on
"Brandon " <bflickinger(a)umail.ucsb.edu> wrote in message
> > Why does this happen?

you are looping through the code for values of t from 0 to 100. M(t) refers to the 't' element of M. M cannot have a 0th element. So just doing this should fix it:

M(t+1)=getframe

Hope that helps.

-Eric
From: Brandon on
"Eric " <nxtgretzky88(a)aol.com> wrote in message <hf9oon$nee$1(a)fred.mathworks.com>...
> "Brandon " <bflickinger(a)umail.ucsb.edu> wrote in message
> > > Why does this happen?
>
> you are looping through the code for values of t from 0 to 100. M(t) refers to the 't' element of M. M cannot have a 0th element. So just doing this should fix it:
>
> M(t+1)=getframe
>
> Hope that helps.
>
> -Eric

Eric,

After doing that, I receive a new error message:


??? Conversion to double from struct is not possible.

Error in ==> P4_2 at 12
M(t+1)=getframe;

Any ideas?
From: Eric on
The error it gave you tells you exactly whats wrong. 0 is not a positive integer.
From: Brandon on
"Eric " <nxtgretzky88(a)aol.com> wrote in message <hf9p6b$jlu$1(a)fred.mathworks.com>...
> The error it gave you tells you exactly whats wrong. 0 is not a positive integer.

I replaced the zero, so the code now reads:

%P4_2

kappa = 1*10^-12; %mm^2/s
Ts = 86400; %temperature fluctuation in section
To = 20; %initial temperature in celsius
deltaT = 5; %change in temperature in celcius
omega = 2*pi/Ts;
z = 1:150;
alpha = sqrt(omega/(2*kappa));
for t=1:100
T = To+deltaT*exp(-alpha*z).*cos(omega*t-alpha*z);
M(t)=getframe;
end
movie(M)

figure(1);
plot(T,z)
xlabel('Temperature (C)')
ylabel('Depth (km)')
set(gca,'ydir','reverse')

but the error message
??? Conversion to double from struct is not possible.

Error in ==> P4_2 at 12
M(t+1)=getframe;
still persists...
From: Brandon on
this is driving me crazy... can someone please help me figure this out?