clf
clear all
set(0,'defaultaxesfontsize',20);
wa=linspace(-26,26,2048);
ws=16;
bandw=20;
miny=-1; maxy=2;
%
%y0=sin(wa*(pi/10)).*rect(wa/bandw);
%y1=sin((wa-ws)*(pi/10)).*rect((wa-ws)/bandw);
%y2=sin((wa+ws)*(pi/10)).*rect((wa+ws)/bandw);
%
%y0=(rect((wa-5)/10)-rect((wa+5)/10)).*rect(wa/bandw);
%y1=(rect((wa-ws-5)/10)-rect((wa-ws+5)/10)).*rect((wa-ws)/bandw);
%y2=(rect((wa+ws-5)/10)-rect((wa+ws+5)/10)).*rect((wa+ws)/bandw);
%
%y0=(wa.*rect(wa/20)).*rect(wa/bandw);
%y1=((wa-ws).*rect((wa-ws)/20)).*rect((wa-ws)/bandw);
%y2=((wa+ws).*rect((wa+ws)/20)).*rect((wa+ws)/bandw);
%
y0=((1-(-wa-6)/4).*rect((wa+8)/4)+rect(wa/12)+(1-(wa-6)/4).*rect((wa-8)/4)).*rect(wa/bandw);
y1=((1-(-(wa-ws)-6)/4).*rect((wa-ws+8)/4)+rect((wa-ws)/12)+(1-(wa-ws-6)/4).*rect((wa-ws-8)/4)).*rect((wa-ws)/bandw);
y2=((1-(-(wa+ws)-6)/4).*rect((wa+ws+8)/4)+rect((wa+ws)/12)+(1-(wa+ws-6)/4).*rect((wa+ws-8)/4)).*rect((wa+ws)/bandw);
%
z=(y0+y1+y2).*rect(wa/ws);
figure(1)
plot(wa,y0,'k','Linewidth',3)
axis([min(wa) max(wa) miny maxy])
hold on
plot(wa,y1,'r','Linewidth',3)
plot(wa,y2,'b','Linewidth',3)
plot(wa,z,'g','Linewidth',3)
plot(wa,zeros(size(wa)),'k','Linewidth',2)
plot([0 0],[miny maxy],'k','Linewidth',2)
plot([ws/2 ws/2],[miny maxy],'--k','Linewidth',2)
plot([-ws/2 -ws/2],[miny maxy],'--k','Linewidth',2)
xlabel('analog frequency (rads/sec)')
hold off