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 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.color = [0.2157, 0.4941, 0.7216]; options.clf = 0; % Clear figure before plotting new 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 if options.clf clf(fig); % Clear the figure if requested end hold on ax = gca; N = numel(ax.Children); % 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 grid on; grid minor xlabel('Coefficient Index'); ylabel('Amplitude'); end % Ensure the layout is tight for better visibility sgtitle('Filter Coefficients'); % Overall title end