Personal tools
  •  

SigspecLab1

Document Actions
  • Bookmarks
  • CourseFeed

Click here to get the file

Size 1 kB - File type text/plain

File contents

             function sigspec(sigin,flag)
if(nargin==0)
  disp('USAGE: sigspec(sigin,flag)');
  disp('   The input signals should be in the columns of sigin.');
  disp('   flag=0 produces a linear magnitude plot (default)');
  disp('   flag=1 produces a log magnitude plot (dB)');
  return;
end

if(nargin==1)
  flag = 0;
end
[len,numsigs]=size(sigin);
if(len<numsigs)
  sigin = sigin.'; % Force the signals into the columns of sigin
  tmp = len;
  len = numsigs;
  numsigs = tmp;
end

fftsize = 2^(ceil(log2(len))+2); % Zero-padded FFT size
f=[0:fftsize-1].'/fftsize - 0.5; % Normalized frequency
sigin = repmat(hamming(len),1,numsigs).*sigin; % Window to reduce spec. leakage
siginspec = abs(fftshift(fft(sigin,fftsize),1)); % Compute spectrum
if(flag)
  plot(f,10*log10(siginspec));
else
  plot(f,siginspec);
end  
xlabel('Normalized Frequency');
ylabel('Magnitude (dB)');
            
Copyright 2008, by the Contributing Authors. Cite/attribute Resource . admin. (2006, July 06). SigspecLab1. Retrieved January 07, 2011, from Free Online Course Materials — USU OpenCourseWare Web site: http://ocw.usu.edu/Electrical_and_Computer_Engineering/Communication_Systems_I_1/sigspec1.m-view.html. This work is licensed under a Creative Commons License Creative Commons License