%% Create Channelizer for HDL Generation
% Create a function that contains a channelizer object and supports HDL 
% code generation.
%% 
% Create the specifications and input signal. The signal has 8 frequency
% channels.
N = 8;
loopCount = 1024;
offsets = [-40 -30 -20 10 15 25 35 -15];
sinewave = dsp.SineWave('ComplexOutput',true,'Frequency', ...
     offsets+(-375:125:500),'SamplesPerFrame',loopCount);
spectrumAnalyzer = dsp.SpectrumAnalyzer('ShowLegend',true, ...
     'SampleRate',sinewave.SampleRate/N);
%% 
% Write a function that creates and calls the channelizer System object(TM). 
% You can generate HDL from this function. 
% 
% <include>HDLChannelizer8.m</include> 
% 
%% 
% Channelize the input data by calling the object for each data sample. 
y = zeros(loopCount/N,N);
validOut = false(loopCount/N,1);
yValid = zeros(loopCount/(N*N),N);
for reps=1:20
   x = fi(sum(sinewave(),2),1,18);
   for loop=1:length(x) 
      [y(loop,:),validOut(loop)]= HDLChannelizer8(x(loop),true);
   end
   yValid = y(validOut == 1,:);
   spectrumAnalyzer(yValid);
end



%% 
% Copyright 2016 The MathWorks, Inc.