www.gusucode.com > UWB_matlab源码程序 > CP0704/cp0704_LSE_pulse_combination.m

    %
% FUNCTION 7.12 : "cp0704_LSE_pulse_combination"
%
% This function implements the LSE
% selection algorithm described in Section 7.2 for the
% determination of a combination of the first 15 Gaussian
% derivatives fitting the FCC indoor emission mask
%
% 'smp' samples of the Gaussian pulse are considered in
% the time interval 'Tmax - Tmin' 
%
% The function receives as input:
% 1) the index 'i' indicating which setting must be adopted
% for the shape factors of the derivatives
% 2) the pulse repetition period Ts
%
% The function returns:
% 1) the best coefficient set 'coefficient'
% 2) the set of derivatives 'derivative'

% The function singles out the best coefficient set in the
% sense of the
% LSE minimization between the combination of the first 15
% derivatives of the Gaussian pulse and the energy signal
% in the time domain corresponding to the FCC emission
% mask
%
% The function then plots the target mask and PSD of
% the waveform obtained through the LSE minimization
% 
% Programmed by Luca De Nardis

function [coefficient, derivative] = ...
   cp0704_LSE_pulse_combination(i,Ts)

% -----------------------------------------------
% Step Zero - Input parameters and initialization
% -----------------------------------------------

Tmin = -4e-9;                             
% lower time interval limit
Tmax = 4e-9;                              
% upper time interval limit
smp = 1024;                               
% number of samples
frequencysmoothingfactor = 4;             
% frequency smoothing factor

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

positivefrequency=linspace(0,(fs/2),N/2);
% initialization of the positive frequency axis
t=linspace(Tmin,Tmax,smp);                                      
% initialization of the time axis
alpha=cp0703_get_alpha_value(i);                                
% loading the alpha vector depending on the input 'i'


for i=1:15

% ---------------------------------------------
% Step One - Pulse waveforms in the time domain
% ---------------------------------------------

    derivative(i,:) = ...
       cp0702_analytical_waveforms(t,i,alpha(i));
    derivative(i,:) = (derivative(i,:)...
       / max(abs(derivative(i,:))));
    
end

% ---------------------------------------------
% Step Two - Determination of the LSE solution to the
% approximation problem
% ---------------------------------------------

timeemissionmask = cp0704_time_mask(Tmin,Tmax,smp);
% determination of the signal generating the mask in the...
%  frequency domain
% application of the LSE method
coefficient = sqrt(Ts * 377) * ...
   lsqlin(derivative',timeemissionmask');
X = fft(coefficient'*derivative,N);
% double-sided MATLAB amplitude spectrum
X = X / N;
% conversion from MATLAB spectrum to Fourier spectrum
E = fftshift(abs(X).^2/(df^2));
% double-sided ESD
Ess = 2 * E((N/2+1):N);
% single-sided ESD  
PSD = 10 * log10 ((1/Ts) * Ess / 377) + 90;
% PSD of the combination in dBm/MHz

% -----------------------------
% Step Three - Graphical output
% -----------------------------

emissionmask = cp0703_generate_mask(N, fs);
% loading the emission mask on N/2 points

figure(1);
plot(positivefrequency/1e6,...
   emissionmask,'r','Linewidth',[2]);
hold on;
PF = plot(positivefrequency/1e6, PSD);
set(PF,'LineWidth',[2]);
AX=gca;
set(AX,'FontSize',12);
set(AX,'FontSize',12);
T=title('LSE combination');
set(T,'FontSize',14);
X=xlabel('Frequency [MHz]');
set(X,'FontSize',14);
Y=ylabel('PSD  [dBm/MHz]');
set(Y,'FontSize',14);
axis([0 10e3 -400 0]);
alphavalue = '\alpha = 0.714 ns';
text(8e3, -100, alphavalue,'BackgroundColor', [1 1 1]);
text(3.5e3, -250, 'LSE combination', 'BackgroundColor',...
   [1 1 1]);
text(5e3, -25, 'FCC UWB indoor emission mask',...
   'BackgroundColor', [1 1 1]);