91 lines
3.3 KiB
Matlab
91 lines
3.3 KiB
Matlab
|
|
|
|
basePath = 'C:\Users\Silas\Documents\MATLAB\Datensätze\sioe_labor\';
|
|
database = DBHandler("pathToDB",[basePath,'silas_labor.db']);
|
|
|
|
filterParams = database.tables;
|
|
filterParams.Configurations = struct( ...
|
|
'bitrate', 336e9, ...
|
|
'db_mode', 0, ...
|
|
'fiber_length', 1, ...
|
|
'interference_attenuation', [], ...
|
|
'interference_path_length', [], ...
|
|
'is_mpi', 1, ...
|
|
'pam_level', 4, ...
|
|
'rop_attenuation', 0 ...
|
|
);
|
|
|
|
filterParams.EqualizerParameters.diff_precode = int32(db_mode.no_db);
|
|
filterParams.EqualizerParameters.equalizer_structure = int32(equalizer_structure.vnle);
|
|
|
|
selectedFields = {'Configurations.run_id' 'Runs.rx_raw_path' 'Configurations.bitrate' 'Configurations.symbolrate' 'Configurations.pam_level' 'Configurations.db_mode' 'Configurations.rop_attenuation' 'Configurations.is_mpi' 'Configurations.interference_attenuation' 'EqualizerParameters.equalizer_structure' 'EqualizerParameters.diff_precode' 'EqualizerParameters.eq_id' 'Measurements.power_pd_in' 'Measurements.power_mpi_interference' 'Measurements.power_mpi_signal' 'Results.BER' 'Results.SNR' 'Results.GMI' 'Results.Alpha'};
|
|
|
|
[dataTable,sql_query] = database.queryDB(filterParams, selectedFields);
|
|
|
|
fixedVars = {'run_id','eq_id','bitrate'};
|
|
resultTable = groupIt(fixedVars,dataTable);
|
|
|
|
|
|
|
|
% Create a new figure
|
|
figure(1);
|
|
hold on
|
|
unique_rates = unique(resultTable.bitrate);
|
|
for i = 1:numel(unique_rates)
|
|
% Plot BER vs. interference_attenuation
|
|
plot(resultTable.power_mpi_signal(resultTable.bitrate==unique_rates(i),:)-resultTable.power_mpi_interference(resultTable.bitrate==unique_rates(i),:), resultTable.BER(resultTable.bitrate==unique_rates(i),:), 'o-', 'LineWidth', 1.5);
|
|
end
|
|
|
|
% Label the axes and add a title
|
|
xlabel('Interference Attenuation');
|
|
ylabel('BER');
|
|
title('BER vs. Interference Attenuation');
|
|
|
|
% Enable grid for better readability
|
|
grid on;
|
|
|
|
beautifyBERplot;
|
|
|
|
|
|
|
|
|
|
function resultTable = groupIt(fixedVars,dataTable)
|
|
|
|
% Group by run_id and eq_id (adjust grouping keys as needed)
|
|
|
|
[G, groupKeys] = findgroups(dataTable(:, fixedVars));
|
|
|
|
% Preallocate a cell array for aggregated data.
|
|
varNames = dataTable.Properties.VariableNames;
|
|
nVars = numel(varNames);
|
|
aggData = cell(height(groupKeys), nVars);
|
|
groupCount = zeros(height(groupKeys), 1); % To store the size of each group
|
|
|
|
% Loop over each group.
|
|
for i = 1:height(groupKeys)
|
|
idx = (G == i); % Logical index for group i
|
|
groupCount(i) = sum(idx); % Count number of rows in this group
|
|
% For each variable in the table:
|
|
for j = 1:nVars
|
|
colData = dataTable.(varNames{j});
|
|
if isnumeric(colData)
|
|
% For numeric data, compute the mean.
|
|
aggData{i, j} = mean(colData(idx));
|
|
else
|
|
% For non-numeric data, take the first entry.
|
|
if iscell(colData)
|
|
aggData{i, j} = colData{find(idx, 1)};
|
|
else
|
|
aggData{i, j} = colData(find(idx, 1));
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
% Convert the aggregated cell array into a table.
|
|
resultTable = cell2table(aggData, 'VariableNames', varNames);
|
|
|
|
% Append the group count as a new column.
|
|
resultTable.nRows = groupCount;
|
|
|
|
end |