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.

ex241.m
% ex241.m:  Plot of Fourier Series					             
clear all
T=-pi: 0.01: pi;  Y= 0*T;	% First function for summing
for ni=0:20				% Global n not allowed as loop index
   n=ni;					
   c=quadL( @fcos, -pi, pi, [ ], [ ], n)/pi;		% Integral for c(n)
      if n==0,  c= c/2;  end				% First term
   s=quadL( @fsin, -pi, pi, [ ], [ ], n)/pi;		% Integral for s(n)
   Y=Y+ c*cos(n*T)+ s*sin(n*T);			% Approximation to f(t)
   figure(1),  plot(T,Y,  T,funf(T)),  grid on
      xlabel('t'),   ylabel('funf(t)'),  pause(0.5)	
   if n>0						% Coefficient vectors for plot
      N(n)=n;	  C(n)=c;  S(n)=s;
   end
end
figure(2),  plot(N,C,'*',N,C,  N,S,'o', N,S),  grid on 
   xlabel('n'),  ylabel('coefficients: c=*,  s=o')

Contact us