function [evmPerPkt,evmPerSC] = evmSetup(cfgEHT)
%evnSetup Creates and return a comm.EVM system object
%
%   [evmPerPkt,evmPerSC] = evmSetup(CFGEHT) returns a comm.EVM system
%   object for given configuration in cfgEHT.
%
%   CFGEHT is a format configuration object of type <a
%   href="matlab:help('ehtMUConfig')">ehtMUConfig</a>.

%   Copyright 2020 The MathWorks, Inc.

narginchk(1,1)
validateattributes(cfgEHT,{'ehtMUConfig'},{'scalar'},mfilename,'format configuration object');

% Use to measure average EVM over EHT MU packet
evmPerPkt = comm.EVM;
evmPerPkt.AveragingDimensions = [1 2 3]; % Nst-by-Nsym-by-Nss
evmPerPkt.Normalization = 'Average constellation power';
evmPerPkt.ReferenceSignalSource  = 'Estimated from reference constellation';
evmPerPkt.ReferenceConstellation = ehtReferenceSymbols(cfgEHT);

% Use to measure average EVM over symbols
evmPerSC = comm.EVM;
evmPerSC.AveragingDimensions = 2; % Nst-by-Nsym-by-Nss
evmPerSC.Normalization = 'Average constellation power';
evmPerSC.ReferenceSignalSource  = 'Estimated from reference constellation';
evmPerSC.ReferenceConstellation = ehtReferenceSymbols(cfgEHT);

end