Minimal changes

Add Theory plots for Silas Diss
This commit is contained in:
Silas Oettinghaus
2026-01-29 16:49:50 +01:00
parent 7eaa4b8791
commit 7eb3364814
8 changed files with 860 additions and 115 deletions

View File

@@ -7,113 +7,133 @@ data = readtable(tablename,"Delimiter",';','DecimalSeparator',',');
% PLOT
% ============================================================
%% 1. DATA EXTRACTION & SETUP
% Extract columns from the table
%% 1. DATA EXTRACTION & SETUP
raw_M = data.M;
raw_baud = data.BaudRate;
raw_net = data.NetRate;
raw_names = string(data.ZoteroCode);
raw_band = string(data.Band); % Spalte 'Band' als String extrahieren
raw_codes = string(data.ZoteroCode);
raw_names = string(data.Name);
raw_band = string(data.Band);
% Filter: Keep only PAM 2, 4, 6, 8 and rows where Rates are not NaN
% Filter Valid Data
target_M = [2, 4, 6, 8];
validIdx = ismember(raw_M, target_M) & ~isnan(raw_baud) & ~isnan(raw_net);
% Apply filter to create the working variables
Mvals = raw_M(validIdx);
baud = raw_baud(validIdx);
netrate = raw_net(validIdx);
codes = raw_codes(validIdx);
names = raw_names(validIdx);
bands = raw_band(validIdx); % Gefilterte Bands
bands = raw_band(validIdx);
% Setup Lists for Formatting
pam_list = target_M;
colors = flip(cbrewer2('SET1',4));
% Visual Settings
colors = lines(4); % 4 Farben für PAM-2,4,6,8
% 2. PLOT
%% 2. PLOT (For Visual Check only)
figure; hold on;
ms = 40; % Marker size (etwas größer für bessere Sichtbarkeit)
lw = 1.5; % Line width für Fit
ms = 20;
lw = 0.5;
for k = 1:length(pam_list) % Loop durch PAM-Formate
for k = 1:length(pam_list)
M = pam_list(k);
% Logical mask for current PAM
idxPam = (Mvals == M);
% Extract for this PAM
x = baud(idxPam);
y = netrate(idxPam);
b = bands(idxPam);
n = names(idxPam);
b = bands(idxPam); % Bands für diese PAM-Gruppe
% Get color for this PAM format
col = colors(k,:);
% ----- LEGEND FLAG -----
firstLegend = true;
% ---- PLOT ALL POINTS (Marker basierend auf Band) ----
for i = 1:sum(idxPam)
% === MARKER LOGIC ===
currentBand = b(i);
if strcmpi(currentBand, 'O')
marker = 'o'; % Kreis für O-Band
elseif strcmpi(currentBand, 'C')
marker = 'd'; % Diamond für C-Band
% Marker Logic
ms = 20;
if strcmpi(b(i), 'O')
marker = 'o';
elseif strcmpi(b(i), 'C')
marker = 'd';
else
marker = 's'; % Fallback (Quadrat), falls andere Bands auftauchen
marker = 's';
end
if strcmpi(n(i), 'THIS WORK')
marker = 'pentagram';
ms = 100;
end
% Plotting
% Plot Scatter
if firstLegend
h = scatter(x(i), y(i), ms, ...
'Marker', marker, ...
'MarkerEdgeColor', col, ...
'MarkerFaceColor', col, ...
scatter(x(i), y(i), ms, 'Marker', marker, ...
'MarkerEdgeColor', col, 'MarkerFaceColor', col, ...
'DisplayName', sprintf('PAM-%d', M));
firstLegend = false;
else
h = scatter(x(i), y(i), ms, ...
'Marker', marker, ...
'MarkerEdgeColor', col, ...
'MarkerFaceColor', col, ...
scatter(x(i), y(i), ms, 'Marker', marker, ...
'MarkerEdgeColor', col, 'MarkerFaceColor', col, ...
'HandleVisibility','off');
end
% ====== CUSTOM DATATIP CONTENT ======
dt = h.DataTipTemplate;
dt.DataTipRows(1).Label = 'Baud rate';
dt.DataTipRows(2).Label = 'Net rate';
dt.DataTipRows(end+1) = dataTipTextRow('Band', b(i)); % Zeigt Band an
dt.DataTipRows(end+1) = dataTipTextRow('Paper', n(i));
end
% ---- Fit (PAM-specific) ----
% Fit lines
if length(x) >= 3
[p, S, mu] = polyfit(x, y, 2);
xfit = linspace(min(x), max(x), 200);
yfit = polyval(p, xfit, S, mu);
plot(xfit, yfit, ':', ...
'LineWidth', lw, ...
'Color', col, ...
'HandleVisibility', 'off');
plot(xfit, yfit, '-', 'LineWidth', lw, 'Color', col, 'HandleVisibility', 'off');
end
end
grid on; box on;
xlabel('Baud rate [GBd]');
ylabel('Net rate [Gb/s]');
title('Transmission Records (Circle=O, Diamond=C)');
legend('Location','northwest');
set(gca,'FontSize',11);
% title('Check Command Window for TikZ Code');
% legend('Location','northwest');
%% 3. GENERATE TIKZ ANNOTATION CODE
% This prints the manual \draw commands to the console
%% GENERATE TIKZ ANNOTATION CODE
% This prints the manual \draw commands to the console
%% GENERATE TIKZ ANNOTATION CODE (Colored Borders + Tiny Font)
%% GENERATE TIKZ ANNOTATION CODE (No Arrow, Close Text)
fprintf('\n\n%% ===========================================================\n');
fprintf('%% COPY THE FOLLOWING LINES INTO YOUR .TEX FILE \n');
fprintf('%% (Paste them just before \\end{axis})\n');
fprintf('%% ===========================================================\n\n');
for i = 1:length(baud)
bx = baud(i);
by = netrate(i);
key = codes(i);
M_val = Mvals(i);
% --- PLACEMENT LOGIC ---
if M_val == 8
% PAM-8: Place Top-Left
% 'south east' anchor means the text's bottom-right corner touches the coordinate
% shift moves it slightly up and left to clear the marker
anchorStr = 'south east';
shiftStr = 'shift={(-3pt, 3pt)}';
else
% Others: Place Bottom-Right
% 'north west' anchor means the text's top-left corner touches the coordinate
% shift moves it slightly down and right
anchorStr = 'north west';
shiftStr = 'shift={(3pt, -3pt)}';
end
% --- PRINT COMMAND ---
% Uses \node directly at the coordinate (axis cs:...)
fprintf('\\node[anchor=%s, %s, font=\\tiny, fill=white, inner sep=1pt] at (axis cs:%.2f, %.2f) {\\cite{%s}};\n', ...
anchorStr, shiftStr, bx, by, key);
end
fprintf('\n')
%% === EXPORT ===
outfile = 'C:\Users\Silas\Documents\latex\JLT_400G copy\media\matlab2tikz\highspeedresults.tikz';
outfile = 'C:\Users\Silas\Documents\latex\JLT_400G_submission\media\matlab2tikz\highspeedresults_test.tikz';
matlab2tikz(outfile, ...
'width','\fwidth', ...
'height','\fheight', ...