Add new minimal example (+ a ton of other, not so important, changes)

This commit is contained in:
Silas Oettinghaus
2025-12-15 15:04:15 +01:00
parent 75dddca1f2
commit 569e72a1fe
43 changed files with 3594 additions and 674 deletions

View File

@@ -347,8 +347,10 @@ classdef Signal
options.fignum = 2025
options.displayname = "";
options.color = [];
options.linestyle = '-';
options.normalizeToNyquist = 0;
options.addDCoffset = 0;
options.normalizeToDC = 0;
options.normalizeTo0dB = 0;
options.max_num_lines = []; % Leave empty or omit to disable line rotation
options.fft_length = [];
@@ -361,6 +363,8 @@ classdef Signal
options.fft_length = 2^(nextpow2(length(obj.signal))-9);
end
if options.normalizeToNyquist == 0
[p_lin,f_Hz] = pwelch(obj.signal, hanning(options.fft_length), ...
options.fft_length/2, options.fft_length, ...
@@ -374,6 +378,8 @@ classdef Signal
% We'll keep f_rad for the x-axis in that mode.
end
% p_lin = movmean(p_lin,4);
if options.normalizeTo0dB
p_lin = p_lin ./ max(p_lin);
p_dbm = 10*log10(p_lin); % normalized to 0 dB
@@ -418,11 +424,18 @@ classdef Signal
p_dbm = p_dbm+options.addDCoffset;
if options.normalizeToDC
[~,min_idx]=min(abs(f_GHz));
pow_at_dc = p_dbm(min_idx);
p_dbm = p_dbm-pow_at_dc;
end
% p_dbm = movmean(p_dbm,10);
for s = 1:min(size(p_dbm))
if isempty(options.color)
plot(x_vec, p_dbm(:,s), 'DisplayName', options.displayname, 'LineWidth', 1);
else
plot(x_vec, p_dbm(:,s), 'DisplayName', options.displayname, 'LineWidth', 1, 'Color', options.color);
plot(x_vec, p_dbm(:,s), 'DisplayName', options.displayname, 'LineWidth', 1, 'Color', options.color,'LineStyle',options.linestyle);
end
end
@@ -968,8 +981,8 @@ classdef Signal
maxA = max(sig(100:end-100))*1.3;
minA = min(sig(100:end-100))*1.3;
% maxA = 0.0025;
% minA = 0;
maxA = 0.12;
minA = -0.08;
difference= maxA-minA;

View File

@@ -139,6 +139,8 @@ classdef ChannelFreqResp < handle
fnew = linspace(0,fstarget/2,length(Target)/2+1);
fnew = fnew(2:end-1);
% Old frequency axis (should be much coarser)
idx_old = find((obj.faxis > 0) .* (obj.faxis < fstarget/2)); %positions of all Frequencies smaller than fs/2
int_fold = obj.faxis(idx_old); %old frequencies from 0 to fs/2
@@ -149,6 +151,10 @@ classdef ChannelFreqResp < handle
% interpolate the frequency response that had a coarse frequency resolution (e.g. 256 bins) to the current frequency resolution (e.g. 21843 bins)
iH = interp1(int_fold, real(H_inv(idx_old)) ,fnew, 'linear') + 1i*interp1(int_fold, imag(H_inv(idx_old)) ,fnew, 'linear');
if 0
figure(7);hold on;plot(fnew,20*log10(abs(iH)))
end
% set all NaN values to the fist/ last non-NaN value
nH = find(~isnan(iH),1,'first');
iH(1:nH)=iH(nH);
@@ -171,6 +177,8 @@ classdef ChannelFreqResp < handle
% five frequencies -> should be the vaue at f=0=DC component?
iH = iH./mean(abs(iH)); %why 1:5??
dc = 20*log10(abs(mean(abs(iH(1:5)))));
% set maximum amplification
% set als values higher than hmax to hmax and keep the
% phase information by multiplication with respective

View File

@@ -164,8 +164,8 @@ classdef ML_MLSE < handle
% EQUALIZE
% ==============================================================
function [y,y_ref] = equalize(obj,x,d,mu,epochs,N,training)
debug = 1;
showPlots = 1;
debug = 0;
showPlots = 0;
y = zeros(N,1);
nSymbols = ceil(N/obj.sps);

View File

@@ -71,16 +71,22 @@ classdef Metricstruct
end
end
function print(obj)
function print(obj,options)
% Print method to display key metrics in a formatted way
arguments
obj
options.description = '';
end
% 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([char(options.description),' Results \n']);
fprintf('%s\n', repmat('=', 1, nameWidth + valueWidth));
% Function to format numbers with appropriate precision

View File

@@ -21,7 +21,7 @@ height = 200;
plotJob.Position = [100 100 width 100+height];
cols = cbrewer2("paired",12);
plotJob.color = cols(1,:);
plotJob.l = 2;
plotJob.l = 10;
plotJob.ch = 16;
plotJob.d = 0;
plotJob.sgm = 0;
@@ -30,7 +30,7 @@ plotJob.p_in = 3;
plotJob.gamma = 0.0023;
plotJob.pmd = 0.1;
plotJob.channelspacing = 400e9;
plotJob.randzdw = 0;
plotJob.randzdw = 1;
plotJob.plot_ber_curve = 0;
@@ -52,7 +52,7 @@ plotJob.yAxisLabel = 'BER';
% createbercurves(wh,plotJob)
P = [3,6];
P = [3];
for i = 1:2
plotJob.p_in = P(i);
createviolinplots(wh,plotJob);
@@ -234,8 +234,8 @@ Title = ["Co Pol.","Link Segmentation","Paired Pol. Interl.","Alternating Pol. I
D = [0,3,0,0];
Sgm = [0,1,0,0];
colidx = [3];
Len = [10];
colidx = [4];
Len = plotJob.l;
fig = findall(groot, 'Type', 'figure', 'Name', plotJob.figName);
if isvalid(fig)