⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cp0703_random_coefficients.m

📁 这是一本超宽带通信书籍< 超宽带无线通信>>的原代码,ds_uwb,mb_ofdm,脉冲信号的形成
💻 M
字号:
%
% FUNCTION 7.11 : "cp0703_random_coefficients"
%
% This function selects coefficients for a set of base
% functions in order to fit a given emission mask.
%
% The function receives in input:
% 1) the number of attempts in the random selection of the
%    coefficients 'attempts'
% 2) the set of base functions 'basefunction'
% 3) the sampling period 'dt'
% 4) the number of samples in the time domain 'smp'
% 5) the Pulse Repetition Period Ts
% 6) the frequency smoothing factor 'freqsmoothfactor' 
% 7) the target emission mask
% 8) and 9) the range of base functions to be used in the
%    mask fitting, given by the values 'lowerbasefunction'
%    and 'higherbasefunction'
% 
% The function returns:
% 1) the best coefficient set 'c'
% 2) a flag on the validity of the returned set 'result'

% The function individuates the best coefficient set for
% the base function set given in input within the sets
% found during the 'attempts' iterations, by comparing the
% PSD of the resulting waveform for each iteration with the
% target emission mask.
% After 'attempts' iterations the function returns the best
% set, defined as the set leading to the waveform with
% maximum power within all sets fitting the mask.
% 
% Programmed by Luca De Nardis

function [c,result] = cp0703_random_coefficients...
   (attempts, basefunction, dt, smp, Ts,...
   freqsmoothfactor, emissionmask, lowerbasefunction,...
   higherbasefunction)

% -----------------------------------------------
% Step Zero - Input parameters and Initialization
% -----------------------------------------------

% sampling frequency
fs = 1 / dt;
% number of samples (i.e. size of the FFT)
N = freqsmoothfactor * smp;                                       % fundamental frequency 
df = 1 / (N * dt);

% Inizialization of the positive frequency axis
positivefrequency=linspace(0,(fs/2),N/2);
% Inizialization of the coefficient set vector
a=zeros(1,15);
% Inizialization of the random number generator
rand('state',sum(100*clock)); 

% ---------------------------------------------------------
% Step One: Evaluation of the best combination through
%           random search
% ---------------------------------------------------------

for numattempts=1:attempts

  % Inizialization of the power vector component for the
  % actual attempt
  P(numattempts)=0;
  % Inizialization of the coefficient set vector for the
  % actual attempt
  C(numattempts,1:15)=nan; 
  for i=lowerbasefunction:higherbasefunction
        count = 0;
        while (count < 100)
            count=count+1;
            if rand < (0.5)
                a(i) = rand;
            else
                a(i) = -rand;
            end
            % Generation of the waveform associated to the
            %actual coefficient set
            combo=a * basefunction;
            % double-sided MATLAB amplitude spectrum
            X=fft(combo,N);
            % conversion from MATLAB spectrum to Fourier
            % spectrum
            X=X/N;
            % DOUBLE-SIDED ESD of the waveform
            E = fftshift(abs(X).^2/(df^2));
            % SINGLE-SIDED ESD of the waveform
            Ess = 2.*E((N/2+1):N);
            % PSD of the combination in dBm/MHz
            PSD = 10 * log10 ((1/Ts) * Ess / 377) + 90;            

            % Comparison between the PSD and the mask
            if all(PSD < emissionmask)  
                % Recording the power associated to the
                % actual set
                found=1;
                % Recording the actual set
                P(numattempts)=sum(1/Ts .* Ess.*df / 377);
                C(numattempts,1:15)=a;
                count=100;
            end
        end
    end
end

result = found;  % Setting the flag for function output
if(found==1)    
    [m,h]=max(P);% Selection of the set leading to the
                 % waveform at highest power 
    c=C(h,1:15); % Recording the set for function output
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -