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

F_EVM_Computation_on_Symbols.m 4.02 KB
Newer Older
Martin Hudlicka's avatar
Martin Hudlicka committed
1
function [G_OPT,EVM] = F_EVM_Computation_on_Symbols(params,Symb,Sideal)
Martin Hudlicka's avatar
Martin Hudlicka committed
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
% 
% Copyright 2021 IEEE P1765 Authors
% 
% * Redistribution and use in source and binary forms, with or without modification, 
% are permitted provided that the following conditions are met:
% 
% * Redistributions of source code must retain the above copyright notice, 
% this list of conditions and the following disclaimer. 
% 
% * Redistributions in binary form must reproduce the above copyright notice,
% this list of conditions and the following disclaimer in the documentation 
% and/or other materials provided with the distribution.
% 
% * Neither the name of the copyright holder nor the names of its contributors
% may be used to endorse or promote products derived from this software without
% specific prior written permission.
% 
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
% THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 
% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
% DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
% SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
% OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
% USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
% 
% SPDX-License-Identifier: BSD-3-Clause
% 
% See the LICENSE file distributed with this work for copyright and licensing
% information, the AUTHORS file for a list of copyright holders, and the 
% CONTRIBUTORS file for the list of contributors.
% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% This function performs EVM computation on symbols
% Refer to Section: Determine the EVM of the User-Lab and Reference-Lab 
% Measured Waveforms in the IEEE P1765 Document.
% 
% 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
Martin Hudlicka's avatar
Martin Hudlicka committed
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

    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');
Martin Hudlicka's avatar
Martin Hudlicka committed
66
    fprintf(' amplitude = %8.6f    phase = %8.2f °\n',...
Martin Hudlicka's avatar
Martin Hudlicka committed
67
68
69
70
71
72
73
74
75
76
77
78
79
        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');
Martin Hudlicka's avatar
Martin Hudlicka committed
80
%         fprintf(' cos2 = %8.6f    angle = %10.6f °\n',cos2,acosd(sqrt(cos2)));
Martin Hudlicka's avatar
Martin Hudlicka committed
81
82
83
84
85
86
87
88
89
90
91
%     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
Martin Hudlicka's avatar
Martin Hudlicka committed
92
        F_Plot_Constellation_Diagram_OFDM(Sideal,Symb,params);
Martin Hudlicka's avatar
Martin Hudlicka committed
93
94
    end

Martin Hudlicka's avatar
Martin Hudlicka committed
95
end