Changes from mwork PC.
PDP 2025 MPI analysis new focus on database and SQL
This commit is contained in:
@@ -1,58 +1,67 @@
|
||||
function showEQcoefficients(n1, n2, n3, options)
|
||||
% Show filter coefficients as stem plot
|
||||
% n1, n2, and n3 in different subplots
|
||||
% Scale all y-axis to -1 and 1
|
||||
function showEQcoefficients(options)
|
||||
% Show filter coefficients as stem plots.
|
||||
% Only the provided coefficient arrays (n1, n2, n3) are shown,
|
||||
% each in its own subplot. The y-axis is scaled to [-1, 1].
|
||||
|
||||
arguments
|
||||
n1
|
||||
n2
|
||||
n3
|
||||
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.n1 = [];
|
||||
options.n2 = [];
|
||||
options.n3 = [];
|
||||
options.fignum (1,1) double = NaN; % Default: create new figure if NaN
|
||||
options.displayname (1,:) char = ''; % Default: empty string
|
||||
options.color = [0.2157, 0.4941, 0.7216];
|
||||
options.clf = 0; % Clear figure before plotting new
|
||||
options.clf = 0; % Clear figure before plotting if set to 1
|
||||
end
|
||||
|
||||
% Determine the figure number to use or create a new figure
|
||||
% Determine the figure number to use or create a new one.
|
||||
if isnan(options.fignum)
|
||||
fig = figure; % Create a new figure and get its handle
|
||||
fig = figure;
|
||||
else
|
||||
fig = figure(options.fignum); % Use the specified figure number
|
||||
fig = figure(options.fignum);
|
||||
end
|
||||
|
||||
if options.clf
|
||||
clf(fig); % Clear the figure if requested
|
||||
clf(fig);
|
||||
end
|
||||
|
||||
hold on
|
||||
ax = gca;
|
||||
N = numel(ax.Children);
|
||||
|
||||
% Set up a colormap for consistent coloring
|
||||
% Set up a colormap for consistent coloring.
|
||||
cmap = linspecer(8);
|
||||
options.color = cmap(mod(N, size(cmap, 1)) + 1, :);
|
||||
|
||||
% Create subplots for n1, n2, n3
|
||||
for i = 1:3
|
||||
subplot(3, 1, i);
|
||||
switch i
|
||||
case 1
|
||||
stem(n1, 'Color', options.color, 'LineWidth', 1,'Marker','.','MarkerSize',10);
|
||||
title(sprintf('1st order Filter Coefficients: %d',numel(n1)));
|
||||
case 2
|
||||
stem(n2, 'Color', options.color, 'LineWidth', 1,'Marker','.','MarkerSize',10);
|
||||
title(sprintf('2nd order Filter Coefficients: %d',numel(n2)));
|
||||
case 3
|
||||
stem(n3, 'Color', options.color, 'LineWidth', 1,'Marker','.','MarkerSize',10);
|
||||
title(sprintf('3rd order Filter Coefficients: %d',numel(n3)));
|
||||
end
|
||||
ylim([-1, 1]); % Scale y-axis to -1 and 1
|
||||
% Build cell arrays for coefficients and their corresponding titles.
|
||||
coeffs = {};
|
||||
titles = {};
|
||||
|
||||
if ~isempty(options.n1)
|
||||
coeffs{end+1} = options.n1;
|
||||
titles{end+1} = sprintf('1st order Filter Coefficients: %d', numel(options.n1));
|
||||
end
|
||||
if ~isempty(options.n2)
|
||||
coeffs{end+1} = options.n2;
|
||||
titles{end+1} = sprintf('2nd order Filter Coefficients: %d', numel(options.n2));
|
||||
end
|
||||
if ~isempty(options.n3)
|
||||
coeffs{end+1} = options.n3;
|
||||
titles{end+1} = sprintf('3rd order Filter Coefficients: %d', numel(options.n3));
|
||||
end
|
||||
|
||||
numSubplots = numel(coeffs);
|
||||
|
||||
for i = 1:numSubplots
|
||||
subplot(1, numSubplots, i);
|
||||
stem(coeffs{i}, 'Color', options.color, 'LineWidth', 1, ...
|
||||
'Marker', '.', 'MarkerSize', 10);
|
||||
title(titles{i});
|
||||
ylim([-1, 1]); % Set y-axis limits to [-1, 1]
|
||||
grid on;
|
||||
grid minor
|
||||
grid minor;
|
||||
xlabel('Coefficient Index');
|
||||
ylabel('Amplitude');
|
||||
end
|
||||
|
||||
% Ensure the layout is tight for better visibility
|
||||
sgtitle('Filter Coefficients'); % Overall title
|
||||
end
|
||||
sgtitle('Filter Coefficients'); % Overall title for the figure
|
||||
end
|
||||
|
||||
36
Functions/EQ_visuals/showEQfilter.m
Normal file
36
Functions/EQ_visuals/showEQfilter.m
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
function showEQfilter(coefficients,fs)
|
||||
|
||||
% Assuming that obj.e contains the final FFE filter coefficients.
|
||||
% Set the number of frequency points and sampling frequency.
|
||||
nfft = 1024; % Number of frequency points
|
||||
|
||||
% Compute the frequency response of the FFE filter.
|
||||
[H, f] = freqz(coefficients, 1, nfft, fs);
|
||||
|
||||
% Keep only the first half of the frequency response (up to the Nyquist frequency).
|
||||
half_nfft = floor(nfft/2) + 1;
|
||||
f = f(1:half_nfft);
|
||||
H = H(1:half_nfft);
|
||||
|
||||
% Plot the magnitude and phase responses.
|
||||
figure;
|
||||
|
||||
% Magnitude response (in dB)
|
||||
subplot(2,1,1);
|
||||
hold on
|
||||
plot(f.*1e-9, 20*log10(abs(1./H)));
|
||||
title('(Inverted) Magnitude Response of FFE Filter');
|
||||
xlabel('Frequency (Hz)');
|
||||
ylabel('Magnitude (dB)');
|
||||
grid on;
|
||||
|
||||
% Phase response
|
||||
subplot(2,1,2);
|
||||
plot(f.*1e-9, unwrap(angle(H)));
|
||||
title('Phase Response of FFE Filter');
|
||||
xlabel('Frequency (Hz)');
|
||||
ylabel('Phase');
|
||||
grid on;
|
||||
|
||||
end
|
||||
@@ -39,7 +39,9 @@ end
|
||||
intermediate = received_sd(lvl,:);
|
||||
cnt(lvl) = round(numel(intermediate(~isnan(intermediate)))./length(eq_signal),3).*100;
|
||||
hold on
|
||||
warning off
|
||||
histogram(received_sd(lvl,:),1000,"EdgeAlpha",0,'DisplayName',['Lvl ',num2str(lvl),' | ',num2str(cnt(lvl)),' %'],'FaceColor',lvlcol(lvl,:),'Normalization','pdf');
|
||||
warning on
|
||||
end
|
||||
legend
|
||||
grid on
|
||||
|
||||
Reference in New Issue
Block a user