Add new functions
This commit is contained in:
44
Functions/EQ_visuals/showEQNoisePSD.m
Normal file
44
Functions/EQ_visuals/showEQNoisePSD.m
Normal file
@@ -0,0 +1,44 @@
|
||||
function showEQNoisePSD(eq_noise, options)
|
||||
arguments
|
||||
eq_noise
|
||||
options.postfilter_taps = NaN
|
||||
options.fignum (1,1) double = NaN % Default to NaN if not provided
|
||||
options.displayname (1,:) char = '' % Default to an empty string if not provided
|
||||
options.color = [0.2157 0.4941 0.7216];
|
||||
end
|
||||
|
||||
% Determine the figure number to use or create a new figure
|
||||
if isnan(options.fignum)
|
||||
fig = figure; % Create a new figure and get its handle
|
||||
else
|
||||
fig = figure(options.fignum); % Use the specified figure number
|
||||
end
|
||||
hold on
|
||||
ax = gca;
|
||||
% N = numel(ax.Children);
|
||||
N = sum(arrayfun(@(x) strcmp(x.LineStyle, '-'), ax.Children));
|
||||
cmap = linspecer(8);
|
||||
options.color = cmap(mod(N, size(cmap, 1)) + 1, :);
|
||||
|
||||
% Ensure the figure is ready before calling spectrum
|
||||
eq_noise.spectrum("displayname", options.displayname, "fignum", fig.Number, "normalizeTo0dB", 1,"color",options.color);
|
||||
title('Noise of soft decision signal (not MLSE)')
|
||||
|
||||
if ~isnan(options.postfilter_taps)
|
||||
% Hold on to the figure for further plotting
|
||||
hold on;
|
||||
|
||||
% Compute the frequency response of the postfilter
|
||||
[h, w] = freqz(1, options.postfilter_taps, length(eq_noise), "whole", eq_noise.fs);
|
||||
h = h / max(abs(h)); % Normalize the filter response
|
||||
|
||||
% Adjust frequency axis to center at 0
|
||||
w_ = (w - eq_noise.fs / 2);
|
||||
|
||||
% Plot the inverted postfilter response
|
||||
plot(w_ * 1e-9, 20 * log10(fftshift(abs(h))), 'DisplayName', ['Burg Coeffs: ', num2str(round(options.postfilter_taps, 2)), ' '], 'LineWidth', 1,'Color',options.color,'LineStyle','--');
|
||||
|
||||
% Ensure a legend is displayed
|
||||
legend('show');
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user