Many changes

This commit is contained in:
Silas Oettinghaus
2025-02-14 14:54:03 +01:00
parent 2be1254611
commit becaf3f6c9
26 changed files with 1507 additions and 1052 deletions

View File

@@ -4,8 +4,8 @@ classdef Postfilter < handle
properties(Access=public)
ncoeff = 2;
burg_coeff = [];
coefficients = [];
useBurg = NaN
end
methods (Access=public)
@@ -14,7 +14,9 @@ classdef Postfilter < handle
% Detailed explanation goes here
arguments
options.ncoeff double = 2
options.useBurg = NaN
options.coefficients = []
options.ncoeff double = 2
end
%
@@ -24,15 +26,37 @@ classdef Postfilter < handle
obj.(fn{n}) = options.(fn{n});
end
end
% do more stuff
end
function signalclass_out = process(obj,signalclass_in,noiseclass_in)
function signalclass_out = process(obj,signalclass_in,noiseclass_in,options)
obj.burg_coeff = arburg(noiseclass_in.signal,obj.ncoeff);
signalclass_in = signalclass_in.filter(obj.burg_coeff,1);
arguments
obj
signalclass_in
noiseclass_in
options.useBurg = obj.useBurg;
options.coefficients = obj.coefficients;
end
if ~isnan(options.useBurg) && options.useBurg
disp('using burg alg')
obj.coefficients = arburg(noiseclass_in.signal,obj.ncoeff);
elseif ~isempty(options.coefficients)
disp('using given taps')
obj.coefficients = options.coefficients;
obj.useBurg = 0;
else
end
signalclass_in = signalclass_in.filter(obj.coefficients,1);
% append to logbook
lbdesc = ['Postfilter'];
@@ -43,15 +67,29 @@ classdef Postfilter < handle
end
function showFilter(obj,noiseclass_in)
function showFilter(obj,noiseclass_in,options)
noiseclass_in.spectrum('displayname','Noise PSD shifted to 0dBm','fignum',121,'normalizeTo0dB',1);
arguments
obj
noiseclass_in
options.fignum = 121
options.color = []
end
[h,w] = freqz(1,obj.burg_coeff,length(noiseclass_in),"whole",noiseclass_in.fs);
% noiseclass_in.spectrum('displayname','Noise PSD shifted to 0dBm','fignum',options.fignum,'normalizeTo0dB',1);
figure(options.fignum)
[h,w] = freqz(1,obj.coefficients,length(noiseclass_in),"whole",noiseclass_in.fs);
h = h/max(abs(h));
hold on
w_ = (w - noiseclass_in.fs/2);
plot(w_.*1e-9,20*log10(fftshift(abs(h))),'DisplayName',['Burg Coeffs: ', num2str(obj.burg_coeff), ' ']);
if isempty(options.color)
plot(w_.*1e-9,20*log10(fftshift(abs(h))),'DisplayName',['Burg Coeffs: ', num2str(round(obj.coefficients,2)), ' '],'LineWidth',2);
else
plot(w_.*1e-9,20*log10(fftshift(abs(h))),'DisplayName',['Burg Coeffs: ', num2str(round(obj.coefficients,2)), ' '],'Color',options.color,'LineWidth',2);
end
ylim([-30,2]);
end

View File

@@ -57,7 +57,7 @@ classdef VNLE < handle
end
function [X] = process(obj, X, D)
function [X,N] = process(obj, X, D)
% actual processing of the signal (steps 1. - 3.)
% 1 normalize RMS
@@ -91,6 +91,9 @@ classdef VNLE < handle
lbdesc = [num2str(obj.order),' tap FFE'];
X = X.logbookentry(lbdesc); % append to logbook
N = X;
N = X - D;
end
@@ -156,7 +159,6 @@ classdef VNLE < handle
end
if ~all(mu==0,'all') %mu has not only zeros
% obj.e = obj.e - (mu * err * x_in) ; % Weight update rule of LMS
obj.e = obj.e - ( (mu * x_in) * err ) ; % Weight update rule of LMS
else
normalizationfactor = (x_in.' * x_in);