function [G_OPT,EVM] = F_EVM_Computation_on_Symbols(params,Symb,Sideal) % % 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 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 F_Plot_Constellation_Diagram_OFDM(Sideal,Symb,params); end end