Code covered by the BSD License  

Highlights from
Testbench to determine the harmonic order of a SimRF Circuit Envelope simulation

image thumbnail

Testbench to determine the harmonic order of a SimRF Circuit Envelope simulation

by

 

Determine the harmonic order to find the best tradeoff between simulation time and accuracy.

multi_tone_compute( F1, O1, F2, O2, F3, O3, F4, O4)
function [freqs] = multi_tone_compute( F1, O1, F2, O2, F3, O3, F4, O4)
%% Compute unique sums and differences of multiples of two input frequencies 
%  
%  F1,F2, .. = Frequency 1, 2 etc
%  O1,O2, .. = Maximum Order for F1,F2, etc (>=1)
%  F1 through O2 are required. F3 through O4 are optional. 
%  Inputs must be in pairs
%  Dick Benson, May 2013
%  Copyright 2013 The MathWorks, Inc.

   tone_vec=[0];  % dynamic size allocation is employed ...
                  % since execution speed for this function is not
                  % critical.
   freqs  = [];
   k=1;
   if nargin < 4 
      error('Function:multi_tone_compute','Not enough input arguments')
      return
   end
   
   if nargin > 8 
      error('Function:multi_tone_compute','Too many input arguments')
      return
   end
         
   if nargin ==4    % two tones
      for N=-O1:1:O1
          for M=-O2:1:O2
              k=k+1;
              tone_vec(k)=abs(M*F2 + N*F1);
          end
      end
      
   elseif nargin==6   % three tones
       for N=-O1:1:O1
           for M=-O2:1:O2
               for O=-O3:1:O3
                   k=k+1;
                   tone_vec(k)=abs(O*F3 + M*F2 + N*F1);
               end
           end
       end
   
   elseif nargin==8   % four tones
       for N=-O1:1:O1
          for M=-O2:1:O2
              for O=-O3:1:O3
                  for P=-O4:1:O4
                      k=k+1;
                      tone_vec(k)=abs(P*F4 + O*F3 + M*F2 +N*F1);
                  end
              end
          end
       end
   
   else
      error('Function:multi_tone_compute','Incorrect number of input arguments')
      return
       
   end
 
   freqs=unique(tone_vec);
end

  

Contact us