91 lines
2.5 KiB
Matlab
91 lines
2.5 KiB
Matlab
% load data points from BER plot C:/Users/Silas/Documents/MATLAB/imdd_simulation/Projects/Messung_Zürich/BER_Silas.fig
|
|
% load data points from NDR plot C:/Users/Silas/Documents/MATLAB/imdd_simulation/Projects/Messung_Zürich/NDR_Silas.fig
|
|
|
|
% use Functions/Metrics/TransmissionPerformance.m to calculate the NDR from the BER values
|
|
|
|
% 09. April 2026 - während plasmonic JLT review prozess
|
|
|
|
ber = get_xy_from_fig("C:/Users/Silas/Documents/MATLAB/imdd_simulation/Projects/Messung_Zürich/BER_Silas.fig");
|
|
tp = TransmissionPerformance;
|
|
|
|
% 1 = PAM2 VNLE ;3=PAM2 DBt
|
|
% 2 = PAM4 VNLE ;4 PAM4 DBt
|
|
|
|
for n = 1:4
|
|
|
|
bps = 2 - mod(n,2);
|
|
|
|
figure(3);hold on
|
|
plot(ber(n).X,ber(n).Y,'DisplayName','ber')
|
|
set(gca,'YScale','log');
|
|
xlim([96,256]);
|
|
ylim([1e-4, 0.5]);
|
|
beautifyBERplot;
|
|
|
|
ndr = tp.calculateNetRate(ber(n).X.*bps,'BER',ber(n).Y);
|
|
|
|
figure(4); hold on
|
|
plot(ber(n).X,ndr.STAIR.NetRate,'DisplayName','ber')
|
|
xlim([96,256]);
|
|
ylim([100,330]);
|
|
beautifyBERplot;
|
|
|
|
figure(5); hold on
|
|
plot(ber(n).X,ndr.KP4_hamming.NetRate,'DisplayName','ber')
|
|
xlim([96,256]);
|
|
ylim([100,330]);
|
|
beautifyBERplot;
|
|
|
|
figure(6); hold on
|
|
plot(ber(n).X,ndr.O_FEC.NetRate,'DisplayName','ber')
|
|
xlim([96,256]);
|
|
ylim([100,330]);
|
|
beautifyBERplot;
|
|
end
|
|
|
|
function data = get_xy_from_fig(figPath)
|
|
%GET_XY_FROM_FIG Silently open a .fig file and extract X/Y data
|
|
%
|
|
% Usage:
|
|
% data = get_xy_from_fig("C:\path\to\myfigure.fig");
|
|
%
|
|
% Output:
|
|
% data(k).Type
|
|
% data(k).DisplayName
|
|
% data(k).X
|
|
% data(k).Y
|
|
|
|
if ~isfile(figPath)
|
|
error('File not found: %s', figPath);
|
|
end
|
|
|
|
% Make sure figures stay invisible
|
|
oldVisible = get(groot, 'DefaultFigureVisible');
|
|
cleanupVisible = onCleanup(@() set(groot, 'DefaultFigureVisible', oldVisible));
|
|
set(groot, 'DefaultFigureVisible', 'off');
|
|
|
|
% Open figure invisibly
|
|
fig = openfig(figPath, 'invisible');
|
|
cleanupFig = onCleanup(@() close(fig));
|
|
|
|
% Find all objects that have XData and YData
|
|
objs = findall(fig, '-property', 'XData', '-and', '-property', 'YData');
|
|
|
|
% Optional: reverse order so it is closer to plotting order
|
|
objs = flipud(objs);
|
|
|
|
data = struct('Type', {}, 'DisplayName', {}, 'X', {}, 'Y', {});
|
|
|
|
for k = 1:numel(objs)
|
|
data(k).Type = get(objs(k), 'Type');
|
|
|
|
if isprop(objs(k), 'DisplayName')
|
|
data(k).DisplayName = get(objs(k), 'DisplayName');
|
|
else
|
|
data(k).DisplayName = '';
|
|
end
|
|
|
|
data(k).X = get(objs(k), 'XData');
|
|
data(k).Y = get(objs(k), 'YData');
|
|
end
|
|
end |