IEEE.org     |     IEEE Xplore Digital Library     |     IEEE Standards     |     IEEE Spectrum     |     More Sites

F_EVM_Computation_on_Symbols.m 3.15 KB
Newer Older
Martin Hudlicka's avatar
Martin Hudlicka committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
function [G_OPT,EVM] = F_EVM_Computation_on_Symbols(params,Symb,Sideal)

    % This function performs EVM computation on symbols according to Section
    % 5.2.1.5 of the IEEE P1765 Baseline EVM Algorithm for OFDM:
    % Determine the EVM of the User-Lab and Reference-Lab Measured Waveforms
    % 
    % Inputs: 
    %   Symb or r(nT): Recovered OFDM symbols
    %   Sideal: Ideal OFDM symbols from ideal signal
    %   params: structure containing the basic communication paramters
    % 
    % Outputs:
    %   G_OPT: Optimum gain on symbols for EVM computation
    %   EVM or Baseline signal EVM: Baseline rms EVM in percent

    global structGlobal

    %------------------------------------
    % computation of  EVM on all symbols
    %------------------------------------

    % Auto and cross-correlations at time 0 for normalization of symbols
    CC = dot(Symb, Sideal);           %   conjugate of Symb * Sideal';
    ACideal = dot(Sideal, Sideal);    %   Sideal * Sideal';
    AC = dot(Symb, Symb);             %   Symb * Symb';

    % normalization of symbols
    G_OPT = CC / AC ;      %   Gsymb = CC / ACideal;

    fprintf('Optimum gain on symbols for EVM computation\n');
    fprintf(' amplitude = %8.6f    phase = %8.2f �\n',...
        abs(G_OPT), angle(G_OPT) * 180 / pi );

    % EVM Calculation same as the single-carrier case Section 5.1.2.5
    EV = G_OPT*Symb - Sideal;
    EVM = sqrt(dot(EV,EV)/dot(Sideal,Sideal));
    
%     % The EVM computation in Lines 42 to 47 follows the same Math as in the
%     % single-carrier case. It computes the same values but with less
%     % computation and errors. Provided here for reference.
%     % Computation of  EVM on symbols
%     cos2 = real(CC*conj(CC) / AC / ACideal);
%     if structGlobal.printdebug
%         fprintf('Angle between measured symbols and reference symbols\n');
%         fprintf(' cos2 = %8.6f    angle = %10.6f �\n',cos2,acosd(sqrt(cos2)));
%     end
%     EVM = sqrt(1/cos2-1); % = tangent of angle
    
    
    fprintf('EVM measured on all symbols\n');
    fprintf(' EVM = %8.4f %%  or  %6.2f dB\n',EVM * 100, 20*log10(EVM));

    % Plot constellation for all symbols
    Symb = Symb * G_OPT * params.Ac;
    Sideal = Sideal * params.Ac;
    if structGlobal.tracedebug >0
        figure1 = figure(25); clf; grid on; box on;
        hold on; axis('square'); 
        axis([-params.N/2 params.N/2 -params.N/2 params.N/2]);
        set(gca,'XTick',(-params.N/2:1:params.N/2));
        set(gca,'YTick',(-params.N/2:1:params.N/2));
        title('Ideal and measured symbols constellations');
        plot(real(Symb(1:params.Nc*params.NS)),imag(Symb(1:params.Nc*params.NS)),'ro')
        plot(real(Sideal(1:params.Nc*params.NS)),imag(Sideal(1:params.Nc*params.NS)),'k*');
        plot(params.Ac*cos(pi*(0:360)/180),params.Ac*sin(pi*(0:360)/180),'-b');
        
        % Saving figure as graphic file in current directory (plot must still be present in MATLAB plot window)
        stri_fig = fullfile(structGlobal.evm_results_folder,strcat(structGlobal.filename,'_baseline.jpg'));		% Change file naming to save as needed
        set(figure1,'PaperPositionMode','auto');
        print(figure1,stri_fig,'-djpeg','-r0');
    end

end