124 lines
4.2 KiB
Matlab
124 lines
4.2 KiB
Matlab
|
|
|
|
filename = "C:\Users\sioe\Nextcloud\Dokumente\02_Ablage_Office\Lab_Data_24\bias_sweep_gigantisch\wh_pam4.mat";
|
|
a = load(filename);
|
|
wh2 = a.wh;
|
|
|
|
|
|
v_bias_vals = wh2.parameter.vbias.values;
|
|
awg_vpp_vals = wh2.parameter.awg_vpp.values;
|
|
eq_mode_vals = wh2.parameter.eq_mode.values;
|
|
eq_mode_show = eq_mode_vals(2);
|
|
eq_modes = ["FFE","FFE+MLSE","DB precoded","DB encoded"];
|
|
|
|
precomp_amp_max_vals = wh2.parameter.precomp_amp_max.values;
|
|
precomp_amp_max_show = precomp_amp_max_vals(2);
|
|
|
|
m = wh2.getStoValue('m',wh2.parameter.vbias.values(1),wh2.parameter.awg_vpp.values(1),wh2.parameter.eq_mode.values(1),wh2.parameter.precomp_amp_max.values(1));
|
|
|
|
figure();
|
|
sgtitle(['PAM ', num2str(m),' | EQ: ', char(eq_modes(eq_mode_show))])
|
|
|
|
|
|
for p = 1:numel(precomp_amp_max_vals)
|
|
precomp_amp_max_show = precomp_amp_max_vals(p);
|
|
subplot1 = subplot(2,3,p);
|
|
|
|
bers = [];
|
|
rop_measured = [];
|
|
cnt = 0;
|
|
for awg_vpp_cur = awg_vpp_vals
|
|
cnt = cnt+1;
|
|
bers(cnt,:) = wh2.getStoValue('ber',v_bias_vals,awg_vpp_cur,eq_mode_show,precomp_amp_max_show);
|
|
rop_measured(cnt,:) = wh2.getStoValue('rop',v_bias_vals,awg_vpp_cur,eq_mode_show,precomp_amp_max_show);
|
|
end
|
|
|
|
[bestber,bestindex] = min(bers,[],'all');
|
|
[awg_pos,v_bias_pos]=ind2sub(size(bers),bestindex);
|
|
bestawgvpp=awg_vpp_vals(awg_pos);
|
|
bestvbias=v_bias_vals(v_bias_pos);
|
|
|
|
disp(['Best Vpp: ',num2str(bestvbias),' V; Best Vpp AWG: ',num2str(bestawgvpp),' V' ])
|
|
|
|
% Compute the logarithm of BER data
|
|
% Adding a small epsilon to avoid log(0)
|
|
epsilon = 1e-12;
|
|
log_bers = log10(bers + epsilon);
|
|
|
|
% Set limits for z-data scaling in log scale
|
|
zmin = log10(1e-4 + epsilon);
|
|
zmax = log10(0.5 + epsilon);
|
|
|
|
% Plot the filled contour plot with log-scaled z-data
|
|
contourf_handle = contourf(v_bias_vals, awg_vpp_vals, log_bers, 'Parent', subplot1, "ShowText",true,"LabelFormat", @mylabelfun);
|
|
|
|
% Set x and y labels with subscripts for clarity
|
|
xlabel('V_{bias}');
|
|
ylabel('V_{pp} AWG');
|
|
title(['Prec. Ampl.: ',num2str(precomp_amp_max_show), 'dB']);
|
|
|
|
% Adjust the grid to display white lines
|
|
grid on;
|
|
set(subplot1, 'GridColor', [1 1 1]); % Set grid color to white
|
|
|
|
% Set limits for z-data scaling
|
|
clim([zmin zmax]);
|
|
|
|
% Adjust the colormap
|
|
colormap(flipud(cbrewer2('RdBu',64)));
|
|
|
|
% Add a colorbar and adjust its ticks to represent actual BER values
|
|
c = colorbar;
|
|
% Set colorbar ticks at log-spaced intervals
|
|
tick_values = [1e-4 1e-3 1e-2 1e-1 0.5];
|
|
tick_positions = log10(tick_values + epsilon);
|
|
set(c, 'Ticks', tick_positions, 'TickLabels', arrayfun(@num2str, tick_values, 'UniformOutput', false));
|
|
|
|
% Store variables in the figure's application data for use in the data tip function
|
|
setappdata(gcf, 'v_bias_vals', v_bias_vals);
|
|
setappdata(gcf, 'awg_vpp_vals', awg_vpp_vals);
|
|
setappdata(gcf, 'bers', bers);
|
|
setappdata(gcf, 'power', rop_measured); % Store the Power data
|
|
|
|
% Set up the data cursor mode to display custom data tips
|
|
dcm_obj = datacursormode(gcf);
|
|
set(dcm_obj, 'UpdateFcn', @customDataTip);
|
|
hold on
|
|
scatter(bestvbias,bestawgvpp,100,"red",'Marker','x','LineWidth',2);
|
|
|
|
end
|
|
|
|
|
|
function labels = mylabelfun(vals)
|
|
lab = 10.^vals;
|
|
labels = arrayfun(@(x) num2str(x, '%.1e'), lab, 'UniformOutput', false);
|
|
end
|
|
|
|
|
|
% Define the custom data tip function
|
|
function txt = customDataTip(~, event_obj)
|
|
% Retrieve stored variables
|
|
v_bias_vals = getappdata(gcf, 'v_bias_vals');
|
|
awg_vpp_vals = getappdata(gcf, 'awg_vpp_vals');
|
|
bers = getappdata(gcf, 'bers');
|
|
power = getappdata(gcf, 'power'); % Retrieve the Power data
|
|
|
|
% Get the position of the data cursor
|
|
pos = event_obj.Position;
|
|
xdata = pos(1);
|
|
ydata = pos(2);
|
|
|
|
% Find the nearest indices in the data arrays
|
|
[~, xInd] = min(abs(v_bias_vals - xdata));
|
|
[~, yInd] = min(abs(awg_vpp_vals - ydata));
|
|
|
|
% Get the corresponding BER and Power values
|
|
berValue = bers(yInd, xInd);
|
|
powerValue = power(yInd, xInd); % Get the Power value
|
|
|
|
% Format the text for the data tip
|
|
txt = {['V_{bias} = ', num2str(xdata)], ...
|
|
['V_{pp} AWG = ', num2str(ydata)], ...
|
|
['BER = ', num2str(berValue, '%.1e')], ...
|
|
['Power = ', num2str(powerValue)]};
|
|
end |