% % This M-file demonstrate the signal components and Fourier Series % % sigcomp.m --- plot the signal components and wave forms % % Signal components: % % Singal I: x(t)=3cos(20*pi*t-pi/4)+5cos(50*pi*t+pi/3) % % fundamantal frequency is 10pi. % T0=1/5;% 2pi/10pi deltaT=T0/50; %50 samples per period t=0:deltaT:2*T0;%plot 2 periods of the signal x1=3*cos(20*pi*t-pi/4);% signal component 1 x2=5*cos(50*pi*t+pi/3);% signal component 2 x=x1+x2;% signal wave form plot(t,x1,'b',t,x2,'r',t,x,'k');legend('x1','x2','x'); % pause % % change the amplitude of the frequency components % x1=4*cos(20*pi*t-pi/4);% signal component 1 x2=1.5*cos(50*pi*t+pi/3);% signal component 2 x=x1+x2;% signal wave form figure;plot(t,x1,'b',t,x2,'r',t,x,'k');legend('x1','x2','x'); % pause % % change the phase shift of the frequency components % x1=3*cos(20*pi*t+pi/5);% signal component 1 x2=5*cos(50*pi*t-2*pi/5);% signal component 2 x=x1+x2;% signal wave form figure;plot(t,x1,'b',t,x2,'r',t,x,'k');legend('x1','x2','x'); % pause % % Another example % w0=20*pi; T0=1/10; deltaT=T0/50; t=0:deltaT:2*T0; x0=1; x1=sin(w0*t); x3=1/3*sin(3*w0*t); x5=1/5*sin(5*w0*t); x7=1/7*sin(7*w0*t); x9=1/9*sin(9*w0*t); y1=x0+x1; y3=y1+x3; y5=y3+x5; y9=y5+x7+x9; figure;plot(t,y1,'b',t,y3,'r',t,y5,'g',t,y9,'k'); legend('dc+fund','upto3rd','upto5th','upto9th'); % % pause % % frequency components with phase shift % x5=1/5*sin(5*w0*t+pi/4); x7=1/7*sin(7*w0*t-pi/3); x9=1/9*sin(9*w0*t+2*pi/3); y5=y3+x5; y9=y5+x7+x9; figure;plot(t,y1,'b',t,y3,'r',t,y5,'g',t,y9,'k'); legend('dc+fund','upto3rd','upto5th','upto9th'); title('5th,7th,9th harmonics with phase shift'); % % pause % close all