Many changes towards simulation of JLT and once again the evaluation of the Highspeed data from Lab experiments 2024
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
classdef Metricstruct
|
||||
% ResultData - Class to store and manage metric data from signal processing results
|
||||
|
||||
|
||||
properties
|
||||
result_id (1,1) double {mustBeNumeric} = NaN
|
||||
run_id (1,1) double {mustBeNumeric} = NaN
|
||||
@@ -24,15 +24,15 @@ classdef Metricstruct
|
||||
|
||||
GMI (1,1) double {mustBeNumeric} = NaN
|
||||
AIR (1,1) double {mustBeNumeric} = NaN
|
||||
Alpha (:,1) double {mustBeNumeric} = []
|
||||
Alpha (:,1) double {mustBeNumeric} = NaN
|
||||
MLSE_dir (:,1) double {mustBeNumeric} = []
|
||||
end
|
||||
|
||||
|
||||
methods
|
||||
function obj = Metricstruct(varargin)
|
||||
% Constructor method for ResultData
|
||||
% Can be called empty or with name-value pairs
|
||||
|
||||
|
||||
% Process name-value pairs if provided
|
||||
if nargin > 0
|
||||
for i = 1:2:nargin
|
||||
@@ -44,7 +44,7 @@ classdef Metricstruct
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function s = toStruct(obj)
|
||||
% Convert the object to a struct
|
||||
s = struct();
|
||||
@@ -53,7 +53,7 @@ classdef Metricstruct
|
||||
s.(props{i}) = obj.(props{i});
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function str = toString(obj)
|
||||
% Convert the object to a formatted string
|
||||
s = obj.toStruct();
|
||||
@@ -70,9 +70,62 @@ classdef Metricstruct
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function print(obj)
|
||||
% Print method to display key metrics in a formatted way
|
||||
|
||||
% Define the width for formatting
|
||||
nameWidth = 15; % Width for parameter names
|
||||
valueWidth = 12; % Width for values
|
||||
|
||||
% Print header
|
||||
fprintf('\n%s\n', repmat('=', 1, nameWidth + valueWidth));
|
||||
fprintf(' Results \n');
|
||||
fprintf('%s\n', repmat('=', 1, nameWidth + valueWidth));
|
||||
|
||||
% Function to format numbers with appropriate precision
|
||||
function str = formatNumber(value)
|
||||
if isnan(value)
|
||||
str = 'N/A';
|
||||
elseif abs(value) < 0.1 && value ~= 0
|
||||
str = sprintf('%.2e', value);
|
||||
else
|
||||
str = sprintf('%.4f', value);
|
||||
end
|
||||
end
|
||||
|
||||
% Print each metric
|
||||
% BER metrics
|
||||
fprintf('%-*s: %*s\n', nameWidth, 'BER', valueWidth, formatNumber(obj.BER));
|
||||
fprintf('%-*s: %*s\n', nameWidth, 'BER (precoded)', valueWidth, formatNumber(obj.BER_precoded));
|
||||
|
||||
% SNR
|
||||
fprintf('%-*s: %*s\n', nameWidth, 'SNR', valueWidth, formatNumber(obj.SNR));
|
||||
|
||||
% Information rates
|
||||
fprintf('%-*s: %*s\n', nameWidth, 'GMI', valueWidth, formatNumber(obj.GMI));
|
||||
fprintf('%-*s: %*s GBd \n', nameWidth, 'AIR', valueWidth, formatNumber(obj.AIR.*1e-9));
|
||||
|
||||
% Alpha (if it's not empty, show first few values)
|
||||
if ~isempty(obj.Alpha)
|
||||
if length(obj.Alpha) <= 3
|
||||
alphaStr = sprintf('%.4f ', obj.Alpha);
|
||||
else
|
||||
alphaStr = sprintf('%.4f %.4f %.4f...', obj.Alpha(1:3));
|
||||
end
|
||||
fprintf('%-*s: %s\n', nameWidth, 'Alpha', alphaStr);
|
||||
else
|
||||
fprintf('%-*s: %*s\n', nameWidth, 'Alpha', valueWidth, '[]');
|
||||
end
|
||||
|
||||
% Print footer
|
||||
fprintf('%s\n', repmat('=', 1, nameWidth + valueWidth));
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
methods (Static)
|
||||
|
||||
function obj = fromStruct(s)
|
||||
% Create a ResultData object from a struct
|
||||
obj = Metricstruct();
|
||||
@@ -83,5 +136,6 @@ classdef Metricstruct
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user