Files
css/hod4/2.m
2025-11-06 14:59:22 +01:00

29 lines
602 B
Matlab

% y(n)=(3/4)*y(n-1) + (1/6)*y(n-2) + x(n)+(1/2)*x(n-1)
clc;
clear all;
close all;
cit = [1, 0.5]
men = [1, -0.75, -1/6]
roots(men)
figure;
zplane(cit, men);
figure;
freqz(cit, men, 'whole');
x = [zeros(1, 10), 1, zeros(1, 100)]
y = zeros(size(x));
for n = 3:length(x)
y(n) = 0.75*y(n-1) + (1/6)*y(n-2) + x(n) + 0.5*x(n-1)
stem(0:length(x)-1, y, 'filled'); % plot discrete-time sequence
title(['System output up to sample n = ' num2str(n)]);
xlabel('n');
ylabel('y(n)');
ylim([-0.5 1.5]); % fixed axis for stability
grid on;
pause(0.25);
end