No BSD License  

Highlights from
Alternative Mathematics using MATLAB 7

image thumbnail

Alternative Mathematics using MATLAB 7

by

 

13 Mar 2003 (Updated )

Self-instructive text on undergraduate algebra, statistics, differential and integral calculus.

ex202a.m
% ex202a.m:  RKF solution to y"= -c sin(y), Compared				       
clear all,   c=9.81;									% Value of g/L for L=1
while 1==1					
   y1=0;						% Initial angular position
   yp1=input('yp1=  (e.g. 1) ') ;		% Initial angular velocity
   if yp1==0,  break,  end 
   Y_initial=[y1  yp1]'; 			% Transpose to column
   options=odeset('abstol',1e-8,  'reltol',1e-8);		% For ode45
   [T,Y]=ode45('pend',  [0 5],  Y_initial, options);
   figure(1),  plot(T,Y),  title('y"= -c sin(y)'),  grid on,  xlabel('time'),
      legend('y', 'yp')
         a=sqrt(c);  Yex=yp1/a*sin(a*T)+ y1*cos(a*T);   
   figure(1),  plot(T,Y(:,1),  T,Yex),  grid on,  
      legend('Y','Yex'),  xlabel('time')
end

Contact us