Code covered by the BSD License  

Highlights from
Amplitude modulation

Amplitude modulation

by

 

DSBSC, DSBFC,SSBSC USB, SSBSC LSB modulation can be perform

ANALOGCOMM5(action)
function ANALOGCOMM5(action)
% This is a Amplitude Modulation tool box. It can be used for the
% visualization of modulated signal in time domain as well as in frequency
% domain. Messasge signal & carrier signal can also be seen in time as well
% as freq domain. There are five types of functions included for the generation 
% of message signal & carrier signal.For a perticular message function different
% carrier signals can be used to see the modulated signal in time domain as
% well as in frequency domain. The amplitude & frequency of the message & 
% carrier signal can be changed by the user to see the differences in output
% signal in both domains. The maximum frequency limit also can be cganged
% just by changing the sample rate (here, NN=9001 is used) of the sin, 
% cosine, square, trangular or the sawtooth function generator.
% Creator : Suman Saha; MTECH, ECE, KGEC
% Date of complition: 04/05/2013. Time: 8.00pm Total time taken: 6.5hours
if nargin<1,
    action='initialize';
end;
if strcmp(action,'initialize')
    close all;
%============================================
% TOTAL FIGURE
figNumber=figure('Name','A M P L I T U D E   M O D U L A T I O N','NumberTitle','off','Units','inches','Position',[1.2 1.0 9 6],'Resize','off','ToolBar','figure');
colordef(figNumber,'black')
axes('Units','inches','Position',[0.5 0.4 4.8 4.3],'Visible','on');
%==========================================================================
xpos=5.6; ypos=4.6; xw=1.5; yw=0.2;
%popup button for the modulation schemes
cmdListmod=strvcat('NULL','DSBFC','DSBSC','SSBSC LSB','SSBSC USB');
hndl1mod=uicontrol('Style','popup','Units','inches','Position',[xpos-3.4 ypos+0.8 xw+0.3 yw],...
       'ForegroundColor',[0 0 0],'BackgroundColor',[0.9 0.06 0.6],'FontWeight','bold',...
       'String','See Message or Carrier|DSBFC|DSBSC|SSBSC (LSB)|SSBSC (USB)','FontSize',10,...
       'Callback','ANALOGCOMM5 build','UserData',cmdListmod);
uicontrol('Style','text','String','Choose Output Display for Message or Carrier/DSBFC/DSBSC/SSBSC','Units','inches','ForegroundColor',[1 1 1],'FontSize',12,...
         'Position',[0.1 5.65 5 0.2],'BackgroundColor',[0.2 0.2 0.2],'FontName','times new roman','FontWeight','bold');
%==========================================================================
%text for Message signal display
uicontrol('Style','text','Units','inches','Position',[xpos-0.11 ypos+0.4 1.75 0.2],'FontSize',10,...
        'BackgroundColor',[0.2 0.2 0.2],'String','MESSAGE SIGNAL','FontWeight','bold',...
    'FontName','Times new roman','HorizontalAlignment','center','ForegroundColor',[1 1 1]);
%text for Carrier Signal display
uicontrol('Style','text','Units','inches','Position',[xpos+1.68 ypos+0.4 1.75 0.2],'FontSize',10,...
        'BackgroundColor',[0.2 0.2 0.2],'String','CARRIER SIGNAL','ForegroundColor',[1 1 1],...
        'FontName','Times new roman','FontWeight','bold','HorizontalAlignment','center');
%==========================================================================
%%----------FOR MESSAGE SIGNAL-----------%%
%----THE CONSOLE FRAME1----%
h1=uicontrol('Style','frame','Units','inches','Position',[xpos-0.11 ypos-3.08 1.75 3.5], ...
        'BackgroundColor',0.8*[0.5 0.8 0.04]);
h=uicontrol('Style','frame','Units','inches','Position',[xpos-0.06 ypos-3.05 1.6 3.4], ...
        'BackgroundColor',[0.50 0.750 0.050]);
%============================================
% FIRST SLIDER  for message signal
sld1Hndl=uicontrol('Style','slider','Tag','Amplitude','Units','inches', ...
        'Position',[xpos ypos-0.4 xw yw],'BackgroundColor',0.6*[0 1 1],'Callback','ANALOGCOMM5(''build'')');
uicontrol('Style','text','String','Amplitude','Units','inches','FontName','monotype corsiva', ...
        'Position',[xpos ypos xw yw+0.1],'BackgroundColor',0.3*[0 0 1],'FontSize',15,...
        'ForegroundColor',0.9*[1 0 1]);
uicontrol('Style','text','String','  0    <--- [Volt] --->   50','BackgroundColor',0.3*[0 0 1],'FontSize',10,...
        'ForegroundColor',0.9*[0 1 1],'Units','inches','Position',[xpos ypos-0.2 xw yw]);
%============================================
% Text for Inputing Frequency range
uicontrol('Style','text','FontName','Times new roman','FontWeight','bold',...
      'FontSize',10,'HorizontalAlignment','center','Units','inches', ...
      'String','Input Frequency Range','BackgroundColor','yellow', ...
      'Position',[xpos ypos-1.08 xw yw+0.25]);
FF=uicontrol('Style','edit','FontName','monotype corsiva', ...
    'FontSize',14,'HorizontalAlignment','left', ...
    'Units','inches','Max',1,'String','50','BackgroundColor',[0.7 0.7 0.5], ...
    'Callback','ANALOGCOMM5(''build'')','Position',[xpos+0.09 ypos-1.06 xw-0.2 yw]);
%============================================
% SECOND SLIDER for message signal
sld2Hndl=uicontrol('Style','slider','Tag','Frequency','Units','inches', ...
        'Position',[xpos ypos-1.8 xw yw],'BackgroundColor',0.6*[0 1 1],'Callback','ANALOGCOMM5(''build'')');
uicontrol('Style','text','String','Frequency','Units','inches','FontSize',15,'FontName','monotype corsiva', ...
        'Position',[xpos ypos-1.4 xw yw+0.1],'BackgroundColor',0.3*[0 0 1],'ForegroundColor',0.9*[1 0 1]);
uicontrol('Style','text','Tag','DisFreq','Units','inches','ForegroundColor',0.9*[0 1 1],'FontSize',10,...
         'Position',[xpos ypos-1.6 xw yw],'BackgroundColor',0.3*[0 0 1]);
%========================================
%============================================
% TEXT FOR CHOOSE FUNCTION for message signal
uicontrol('Style','text','Units','inches','Position',[xpos ypos-2.4 xw yw+0.1],'String','Choose Function','FontName','times new roman', ...
       'ForegroundColor','black','FontWeight','bold','FontSize',11,'BackgroundColor',[0.50 0.750 0.050]);
% POPUP BUTTON TO SELECT FUNCTION TYPE
cmdList=strvcat('Sine','Cosine','Square','Triangular','Sawtooth');
hndl1=uicontrol('Style','popup','Units','inches','Position',[xpos-0.01 ypos-2.4 xw+0.03 yw-0.1],...
       'ForegroundColor',0.9*[1 1 0],'BackgroundColor',0.3*[0 0 1],'FontWeight','bold',...
       'String','SINE|COSINE|SQUARE|TRIANGULAR|SAWTOOTH','FontSize',9,...
       'Callback','ANALOGCOMM5 build','UserData',cmdList);
%=============================================
%%----------FOR CARRIER SIGNAL-----------%%
%THE CONSOLE FRAME
h1C=uicontrol('Style','frame','Units','inches','Position',[7.3 1.52 1.75 3.5], ...
        'BackgroundColor',0.8*[0.5 0.8 0.04]);
hC=uicontrol('Style','frame','Units','inches','Position',[7.35 1.55 1.6 3.4], ...
        'BackgroundColor',[0.50 0.750 0.050]);
%============================================
% FIRST SLIDER   for carrier signal
sld1HndlC=uicontrol('Style','slider','Tag','AmplitudeC','Units','inches', ...
        'Position',[7.41 4.2 1.5 0.2],'BackgroundColor',0.6*[0 1 1],'Callback','ANALOGCOMM5(''build'')');
uicontrol('Style','text','String','Amplitude','Units','inches','FontName','monotype corsiva', ...
        'Position',[7.41 4.6 1.5 0.3],'BackgroundColor',0.3*[0 0 1],'FontSize',15,...
        'ForegroundColor',0.9*[1 0 1]);
uicontrol('Style','text','String','  0    <--- [Volt] --->   50','BackgroundColor',0.3*[0 0 1],'FontSize',10,...
        'ForegroundColor',0.9*[0 1 1],'Units','inches','Position',[7.41 4.4 1.5 0.2]);
%============================================
% Text for Inputing Frequency range for carrier signal
uicontrol('Style','text','FontName','Times new roman','FontWeight','bold',...
      'FontSize',10,'HorizontalAlignment','center','Units','inches', ...
      'String','Input Frequency Range','BackgroundColor','yellow', ...
      'Position',[7.41 3.52 1.5 0.45]);
FFC=uicontrol('Style','edit','FontName','monotype corsiva', ...
    'FontSize',14,'HorizontalAlignment','left', ...
    'Units','inches','Max',1,'String','50','BackgroundColor',[0.7 0.7 0.5], ...
    'Callback','ANALOGCOMM5(''build'')','Position',[7.5 3.54 1.3 0.2]);
%============================================
% SECOND SLIDER for carrier signal
sld2HndlC=uicontrol('Style','slider','Tag','FrequencyC','Units','inches', ...
        'Position',[7.41 2.8 1.5 0.2],'BackgroundColor',0.6*[0 1 1],'Callback','ANALOGCOMM5(''build'')');
uicontrol('Style','text','String','Frequency','Units','inches','FontSize',15,'FontName','monotype corsiva', ...
        'Position',[7.41 3.2 1.5 0.3],'BackgroundColor',0.3*[0 0 1],'ForegroundColor',0.9*[1 0 1]);
uicontrol('Style','text','Tag','DisFreqC','Units','inches','ForegroundColor',0.9*[0 1 1],'FontSize',10,...
         'Position',[7.41 3 1.5 0.2],'BackgroundColor',0.3*[0 0 1]);
%============================================
% TEXT FOR CHOOSE FUNCTION for carrier signal
uicontrol('Style','text','Units','inches','Position',[7.41 2.2 1.5 0.3],'String','Choose Function','FontName','times new roman', ...
       'ForegroundColor','black','FontWeight','bold','FontSize',11,'BackgroundColor',[0.50 0.750 0.050]);
% POPUP BUTTON TO SELECT FUNCTION TYPE
cmdListC=strvcat('Sine','Cosine','Square','Triangular','Sawtooth');
hndl1C=uicontrol('Style','popup','Units','inches','Position',[7.4 2.2 1.53 0.1],...
       'ForegroundColor',0.9*[1 1 0],'BackgroundColor',0.3*[0 0 1],'FontWeight','bold',...
       'String','SINE|COSINE|SQUARE|TRIANGULAR|SAWTOOTH','FontSize',9,...
       'Callback','ANALOGCOMM5 build','UserData',cmdListC);
%==========================================================================
%---------------Toogle button to display message signal or carrier signal
 sld4Hndl=uicontrol('Style','toggle','Tag','tdis','Units','inches','String','Message/Carrier','FontSize',11,'FontWeight','bold',...
        'Position',[6.31 5.3 1.8 0.3],'BackgroundColor',[0.9 0.06 0.6],'Callback','ANALOGCOMM5(''build'')');
uicontrol('Style','text','String','Choose Display for Message/Carrier','Units','inches','ForegroundColor',[1 1 1],'FontSize',12,...
         'Position',[5.7 5.6 3 0.2],'BackgroundColor',[0.2 0.2 0.2],'FontName','times new roman','FontWeight','bold');
%----CHOOSE time DOMAIN or freauency domain ,TOGGLE BUTTON----%
 sld3Hndl=uicontrol('Style','toggle','Tag','TFreq','Units','inches','String','Time/Freq','FontSize',12,'FontWeight','bold',...
        'Position',[6.44 1 1.4 0.3],'BackgroundColor',[0.9 0.06 0.6],'Callback','ANALOGCOMM5(''build'')');
uicontrol('Style','text','String','Choose Domain Time/Freq','Units','inches','ForegroundColor',[1 1 1],'FontSize',12,...
         'Position',[5.9 1.25 2.4 0.2],'BackgroundColor',[0.2 0.2 0.2],'FontName','times new roman','FontWeight','bold');
%%----SPECIFICATION TEXT-----%%
specstrC=sprintf('Maximum Amplitude 50 Volt\nMaximum freq. 4.499kHz\nMade by Suman Saha');
specification=uicontrol('Style','text','Units','inches','Position',[7.44 0.05 1.5 0.45],'String',specstrC, ...
       'ForegroundColor',[1 1 1],'BackgroundColor',[0.2 0.2 0.2],'FontSize',8);
%%----Initialize button------%%
initialization=uicontrol('Style','push','FontName','Times new roman','FontWeight','bold',...
      'FontSize',12,'HorizontalAlignment','center','Units','inches','String','Initialize',...
      'BackgroundColor',[0.2071    0.6072    0.6299],'Callback','ANALOGCOMM5(''initialize'')','Position',[xpos 0.6 1.4 0.3]);
%%----THE CLOSE BUTTON-----%
closee=uicontrol('Style','push','Units','inches','Position',[xpos 0.2 1.4 0.3],'String','C L O S E','FontName','monotype corsiva', ...
       'ForegroundColor','black','BackgroundColor','red','FontWeight','bold','FontSize',15,'Callback','close(gcf)');
%==========================================================================
%------------Typing the value of Amplitud of Message--------%
uicontrol('Style','text','Tag','Ampl','Units','inches','FontWeight','bold','FontSize',11,...
        'Position',[xpos ypos-0.6 xw yw],'BackgroundColor',0.3*[0 0 1],'ForegroundColor',0.9*[0 1 1]);
%------------Typing the value of Frequency of Message--------%
uicontrol('Style','text','Tag','Freq','Units','inches','FontWeight','bold','FontSize',11,...
        'Position',[xpos ypos-2 xw yw],'BackgroundColor',0.3*[0 0 1],'ForegroundColor',0.9*[0 1 1]);
%------------Typing the value of Amplitud of Carrier--------%
uicontrol('Style','text','Tag','AmplC','Units','inches','FontWeight','bold','FontSize',11,...
        'Position',[xpos+1.8 ypos-0.6 xw yw],'BackgroundColor',0.3*[0 0 1],'ForegroundColor',0.9*[0 1 1]);
     %------------Typing the value of Frequency of Carrier--------%
uicontrol('Style','text','Tag','FreqC','Units','inches','FontWeight','bold','FontSize',11,...
        'Position',[xpos+1.8 ypos-2 xw yw],'BackgroundColor',0.3*[0 0 1],'ForegroundColor',0.9*[0 1 1]);
%==========================================================================
    hndlList=[hndl1,FF,hndl1C,FFC,hndl1mod];
    set(figNumber,'Visible','on','UserData',hndlList);
    ANALOGCOMM5('build');        % call itself to build the defferent function
%============================================
%%---Take Slider Input as well as Popup button input & Redraw---%%
elseif strcmp(action,'build')
        kt=get(findobj(gcf,'Tag','tdis'),'Value');
        TF=get(findobj(gcf,'Tag','TFreq'),'Value');
        hndlList=get(gcf,'UserData');
        [rmod,cmod]=size(hndlList(:,5));
     for countmod=1:rmod
        newStrListmod=get(hndlList(countmod,5),'UserData');
        newStrValmod=get(hndlList(countmod,5),'Value');
        newStrmod=deblank(newStrListmod(newStrValmod,:)); 
     end
        FF=hndlList(2);
        fr=str2num(get(FF(1),'String'));
        FFC=hndlList(4);
        frC=str2num(get(FFC(1),'String'));
        A=50*get(findobj(gcf,'Tag','Amplitude'),'Value');
        F=fr*get(findobj(gcf,'Tag','Frequency'),'Value');
        AC=50*get(findobj(gcf,'Tag','AmplitudeC'),'Value');
        FC=frC*get(findobj(gcf,'Tag','FrequencyC'),'Value');
        [rn,cn]=size(hndlList(:,1));
     for count=1:rn
        newStrList=get(hndlList(count,1),'UserData');
        newStrVal=get(hndlList(count,1),'Value');
        newStr=deblank(newStrList(newStrVal,:));   % Optional
        newStrListC=get(hndlList(count,3),'UserData');
        newStrValC=get(hndlList(count,3),'Value');
        newStrC=deblank(newStrListC(newStrValC,:)); % Optional
     end
  %----------------------------------------------------
      set(findobj(gcf,'Tag','Ampl'),'String',sprintf('%f  Volt',A)); 
      set(findobj(gcf,'Tag','Freq'),'String',sprintf('%f  Hz',F)); 
      set(findobj(gcf,'Tag','DisFreq'),'String',sprintf('  0   <--- [Hz] --->  %d',fr)); 
      set(findobj(gcf,'Tag','AmplC'),'String',sprintf('%f  Volt',AC)); 
      set(findobj(gcf,'Tag','FreqC'),'String',sprintf('%f  Hz',FC)); 
      set(findobj(gcf,'Tag','DisFreqC'),'String',sprintf('  0   <--- [Hz] --->  %d',frC));
      % Default Display Message
      set(findobj(gcf,'Tag','tdis'),'String','MESSAGE'); 
      [tsM,xM,yM]= amardacM(newStrVal,A,F,fr);
      title 'TIME DOMAIN MESSAGE SIGNAL'
  if kt==1  % Display Carrier
      set(findobj(gcf,'Tag','tdis'),'String','CARRIER');
      [tsC,xC,yC]= amardacC(newStrValC,AC,FC,frC);
      title 'TIME DOMAIN CARRIER SIGNAL'
  end
  if newStrValmod==2
         [tsM,xM,yM]= amardacM(newStrVal,A,F,fr);
         [tsC,xC,yC]= amardacC(newStrValC,AC,FC,frC);
         [ts,t,DSBFC]=DSBFCfun(yM,yC,xM,AC); 
         plot(t,DSBFC);
         title 'TIME DOMAIN DSBFC SIGNAL'
  elseif newStrValmod==3
         [tsM,xM,yM]= amardacM(newStrVal,A,F,fr);
         [tsC,xC,yC]= amardacC(newStrValC,AC,FC,frC);
         [ts,t,DSBSC]=DSBSCfun(yM,yC,xM);
         plot(t,DSBSC);
         title 'TIME DOMAIN DSBSC SIGNAL'
  elseif newStrValmod==4
         [tsM,xM,yM]= amardacM(newStrVal,A,F,fr);
         [tsC,xC,yC]= amardacC(newStrValC,AC,FC,frC);
         [ts,t,SSBSC]= SSBSCLSB(yM,yC,xM,F,FC);
         plot(t,SSBSC);
         title 'TIME DOMAIN SSBSC SIGNAL'
   elseif newStrValmod==5
         [tsM,xM,yM]= amardacM(newStrVal,A,F,fr);
         [tsC,xC,yC]= amardacC(newStrValC,AC,FC,frC);
         [ts,t,SSBSC]= SSBSCUSB(yM,yC,xM,F,FC);
         plot(t,SSBSC);
         title 'TIME DOMAIN SSBSC SIGNAL'
  end
   xlabel 'Time (sec) ------>';ylabel 'Amplitude (Volt) ------>';grid on;
   set(findobj(gcf,'Tag','TFreq'),'String','TIME');
   if TF==1
      set(findobj(gcf,'Tag','TFreq'),'String','FREQUENCY');
      if newStrValmod==1&& kt==0
           [tsM,xM,yM]=amardacM(newStrVal,A,F,fr);
           spectrum_analyzer(yM,xM,tsM,'MESSAGE SIGNAL');
      elseif newStrValmod==1&& kt==1
           [tsC,xC,yC]= amardacC(newStrValC,AC,FC,frC);
           spectrum_analyzer(yC,xC,tsC,'CARRIER SIGNAL');
      elseif newStrValmod==2
           [tsM,xM,yM]=amardacM(newStrVal,A,F,fr);
           [tsC,xC,yC]= amardacC(newStrValC,AC,FC,frC);
           [ts,x,y]=DSBFCfun(yM,yC,xM,AC);
           spectrum_analyzer(y,x,ts,'DSBFC SIGNAL');
      elseif newStrValmod==3
           [tsM,xM,yM]=amardacM(newStrVal,A,F,fr);
           [tsC,xC,yC]= amardacC(newStrValC,AC,FC,frC);
           [ts,x,y]=DSBSCfun(yM,yC,xM); 
           spectrum_analyzer(y,x,ts,'DSBSC SIGNAL');
      elseif newStrValmod==4
           [tsM,xM,yM]=amardacM(newStrVal,A,F,fr);
           [tsC,xC,yC]= amardacC(newStrValC,AC,FC,frC);
           [ts,x,y]=SSBSCLSB(yM,yC,xM,F,FC);
           spectrum_analyzer(y,x,ts,'SSBSC LSB SIGNAL');
%  set(get(gca,'Title'),'String','FREQUENCY DOMAIN SSBSC SIGNAL');
      elseif newStrValmod==5
           [tsM,xM,yM]=amardacM(newStrVal,A,F,fr);
           [tsC,xC,yC]= amardacC(newStrValC,AC,FC,frC);
           [ts,x,y]=SSBSCUSB(yM,yC,xM,F,FC);
           spectrum_analyzer(y,x,ts,'SSBSC USB SIGNAL');
      end
  end
drawnow      % for redraw purpose
end        % ending  (initialization)
%===========================Main Program Ends=============================%
%%%==========SUBFUNCTIONS=================%%%
function [ts,t,outcurv]=sincurve(A,F)
    NN=9001;
%      NN(F>10)=F*20;
%      NN(F>100)=2000;
    ts=1/NN;
    t=linspace(0,1,NN);  
    outcurv=A*sin(2*pi*t*F);
    h=plot(t,outcurv,'linew',1.5);
    set( h,'tag','surface1');           % Optional
    %------ Cosine Wave Function--------------%
function [ts,t,outcurv]=coscurve(A,F);   
    NN=9001;
    ts=1/NN;
    t=linspace(0,1,NN); 
    outcurv=A*cos(2*pi*t*F);
    h=plot(t,outcurv,'linew',1.5);
    set( h,'tag','surface1');           % Optional
    %------ Square Wave Function--------------%
function [ts,t,b]=squarew(A,F)
    NN=9001;
    ts=1/NN;
    t=linspace(0,1,NN);
    b=A*square(2*pi*t*F,50);
    ts=1/length(b);
    h=plot(t,b,'y','linew',2.5);
    set( h,'tag','surface1');           % Optional
  %------ Triangular Wave Function--------------%
function [ts,t,x]=track1(A,F)
    NN=9001;
    ts=1/NN;
    t=linspace(0,1,NN);  
    x=A*sawtooth(2*pi*F*t,0.5);
    h=plot(t,x,'linew',2);
    set( h,'tag','surface1');           % Optional
ts=1/length(x);
%------ Swatooth Wave Function--------------%
function [ts,t,x]=sawto(A,F)
    NN=9001;
    ts=1/NN;
    t=linspace(0,1,NN); 
    x=A*sawtooth(2*pi*F*t,1);
    h=plot(t,x,'linew',2);
    set( h,'tag','surface1');           % Optional
%-----------amardac-------------%
function [ts,x,y]=amardacM(newStrVal,A,F,fr)
%------for each popup button's value run respective function type-----%
         if newStrVal==1
                 [ts,x,y]=sincurve(A,F);
         elseif newStrVal==2
                 [ts,x,y]=coscurve(A,F);
         elseif newStrVal==3
                 [ts,x,y]=squarew(A,F);
         elseif newStrVal==4
                 [ts,x,y]=track1(A,F);
         elseif newStrVal==5
                 [ts,x,y]=sawto(A,F);
         end
function [ts,x,y]=amardacC(newStrValC,AC,FC,frC)
%------for each popup button's value run respective function type-----%
         if newStrValC==1
                  [ts,x,y]=sincurve(AC,FC);
         elseif newStrValC==2
                  [ts,x,y]=coscurve(AC,FC);
         elseif newStrValC==3
                  [ts,x,y]=squarew(AC,FC);
         elseif newStrValC==4   
                  [ts,x,y]=track1(AC,FC);
         elseif newStrValC==5
                  [ts,x,y]=sawto(AC,FC);
         end
%%%%%----------------MODULATION SCHEMES-------------------%%%%%
function [ts,t,DSBFC]=DSBFCfun(XM,XC,t,Ac)
ts=1/length(t);
DSBFC=(1+(XM/Ac)).*XC;
function [ts,t,DSBSC]=DSBSCfun(XM,XC,t)
ts=1/length(t);
DSBSC=XM.*XC;
function [ts,t,SSBSC]=SSBSCLSB(XM,XC,t,F,FC)
ts=1/length(t);
DSBSC=XM.*XC;
Maxdsbsc=max(DSBSC);
Maxdsbsc(Maxdsbsc<=1)=4;
N=length(XM);
Wp=2*[FC-F FC-F+1]/N;
Ws=2*[FC-F-2 FC-F+2]/N;
Rp=log10(Maxdsbsc);
Rs=log10(Maxdsbsc+25);
[n,Wn]=cheb1ord(Wp,Ws,Rp,Rs);
[num den]=cheby1(n,Rp,Wn);
SSBSC=filter(num,den,DSBSC);
function [ts,t,SSBSC]=SSBSCUSB(XM,XC,t,F,FC)
ts=1/length(t);
DSBSC=XM.*XC;
Maxdsbsc=max(DSBSC);
Maxdsbsc(Maxdsbsc<=1)=4;
N=length(XM);
Wp=2*[FC+F FC+F+1]/N;
Ws=2*[FC+F-2 FC+F+2]/N;
Rp=log10(Maxdsbsc);
Rs=log10(Maxdsbsc+25);
[n,Wn]=cheb1ord(Wp,Ws,Rp,Rs);
[num den]=cheby1(n,Rp,Wn);
SSBSC=filter(num,den,DSBSC);
%-----------Spectrum Analyzer--------------%
    function spectrum_analyzer(A,t,ts,str)
    Lfft=length(t)/2;
    Lfft=2^ceil(log2(Lfft));
    B=fftshift(fft(A,Lfft))/Lfft;
    w=(-Lfft/2:Lfft/2-1)/(Lfft*ts);
    plot(w,abs(B),'linew',1);
    xlabel('Frequency (Hz) ----> ');
    ylabel('Magnitude ---->');
    grid on
    title(sprintf('FREQUENCY DOMAIN MAGNITUDE SPECTRUM OF %s',str));
%%%%================================END================================%%%%

Contact us