version where the signal is flipped and added together
This commit is contained in:
@@ -1,21 +1,20 @@
|
||||
function [bits,errors,BER] = calc_ber(data_in,data_ref,skip)
|
||||
|
||||
data_ref=logical(data_ref)';
|
||||
data_in = logical(data_in)';
|
||||
data_ref = logical(data_ref)';
|
||||
data_in = logical(data_in)';
|
||||
|
||||
bits = 0;
|
||||
|
||||
% Determine BER
|
||||
|
||||
bits = bits+size(data_in,2)-skip;
|
||||
bits = bits+numel(data_in(:,skip+1:end));
|
||||
|
||||
try
|
||||
errors = sum( data_in(:,skip+1:end,:) ~= data_ref(:,skip+1:end,:),2 );
|
||||
errors = sum( data_in(:,skip+1:end) ~= data_ref(:,skip+1:end),"all" );
|
||||
|
||||
catch
|
||||
%warning('BER calculation not optimal: Arrays have incompatible sizes for this operation.')
|
||||
errors = NaN;
|
||||
end
|
||||
|
||||
% Determine BER
|
||||
BER = sum(errors)/sum(bits);
|
||||
|
||||
end
|
||||
19
Functions/calc_evm.m
Normal file
19
Functions/calc_evm.m
Normal file
@@ -0,0 +1,19 @@
|
||||
function [evm,stdev] = calc_evm(vector_received,vector_ideal)
|
||||
|
||||
error_vector = (vector_received-vector_ideal);
|
||||
|
||||
k = unique(vector_ideal);
|
||||
|
||||
error = repmat(zeros(size(vector_ideal)),1,length(k));
|
||||
|
||||
for lvl = 1:length(k)
|
||||
error(vector_ideal==k(lvl),lvl) = error_vector(vector_ideal==k(lvl));
|
||||
end
|
||||
|
||||
error(error==0) = NaN;
|
||||
|
||||
stdev = std(error,"omitnan");
|
||||
|
||||
error = sqrt(error.^2);
|
||||
evm = sqrt( 1/length(error) .* sum(error.^2,1,'omitnan') ) ;
|
||||
end
|
||||
Reference in New Issue
Block a user