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
|
||||
|
||||
Reference in New Issue
Block a user