finished exercise

This commit is contained in:
2026-06-18 17:10:52 +02:00
parent 9b4a209f38
commit ae0ccf2c56
19 changed files with 340 additions and 222 deletions

View File

@@ -0,0 +1,47 @@
clear; close all; clc;
% Define filter coefficients
b0 = 1;
b = b0 * [1 1 1 1];
a = [1 -1.5 0.625];
% Frequency response
[H,w] = freqz(b,a,1024);
% Magnitude and phase plots
figure;
subplot(2,1,1);
plot(w/pi, 20*log10(abs(H)), 'LineWidth', 1.5);
grid on;
xlabel('Normalized Frequency (\times\pi rad/sample)');
ylabel('Magnitude (dB)');
title('Magnitude Response');
subplot(2,1,2);
plot(w/pi, unwrap(angle(H)), 'LineWidth', 1.5);
grid on;
xlabel('Normalized Frequency (\times\pi rad/sample)');
ylabel('Phase (rad)');
title('Phase Response');
% Define filter coefficients
b0 = 1;
b = b0 * [1 1 1 1];
a = [1 -1.5 0.625];
% Generate impulse signal
n = 0:50;
x = [1 zeros(1,50)];
% Compute impulse response
h = filter(b,a,x);
% Plot impulse response
figure;
stem(n,h,'filled');
grid on;
xlabel('n');
ylabel('h[n]');
title('Impulse Response (0 \leq n \leq 50)');