Notes
Notes - notes.io |
% Define the numerator and denominator of H(z)
num = [1 0.5]; % Corresponds to z + 0.5
den = [1 -1 3/16]; % Corresponds to z^2 + 0 + 3/16
% Compute the poles and zeros
zeros_H = roots(num);
poles_H = roots(den);
% Plot poles and zeros
figure;
zplane(zeros_H, poles_H);
title('Pole-Zero Plot');
grid on;
% Check stability
stable = all(abs(poles_H) < 1);
%disp(['The system is ', char(stable * 'stable' + ~stable * 'unstable')]);
%% 9.5.2
% Create transfer function
sys = tf(num, den, -1); % Specify -1 for discrete-time
% Impulse response
figure;
impulse(sys);
title('Impulse Response');
grid on;
% Step response
figure;
step(sys);
title('Step Response');
grid on;
%% 9.5.3
% Partial fraction decomposition
[r, p, k] = residue(num, den);
disp('Residue:');
disp(r);
disp('Poles:');
disp(p);
disp('Direct term:');
disp(k);
% Closed-form expression of impulse response
% Impulse response can be derived from r and p
%% 9.5.4
% Frequency response
[H, W] = freqz(num, den, 1024);
% Magnitude response
figure;
subplot(2,1,1);
plot(W/pi, 20*log10(abs(H)));
title('Magnitude Response');
xlabel('Normalized Frequency (times pi rad/sample)');
ylabel('Magnitude (dB)');
grid on;
% Phase response
subplot(2,1,2);
plot(W/pi, unwrap(angle(H)) * (180/pi));
title('Phase Response');
xlabel('Normalized Frequency (times pi rad/sample)');
ylabel('Phase (degrees)');
grid on;
%% 9.5 5
A=[1 -1 3/16];
B=[1 0.5];
n=0:0.01:pi;
x = (n>=0).*(sin(0.3*pi.*n + pi/4) + 2*cos(0.1*pi.*n));
y= filter(B,A,x);
[H2,w2]= freqz(B,A,n);
subplot(2,1,1)
stem (n,y);
title('Y[n]')
subplot(2,1,2)
stem(n,x)
title('X[n]')
%% 9.6
A = [1 1.25 0.75]; %coefficients of y[n]+1.25y[n-1]+0.75y[n-2]
B = [2 1];
n=0:0.01:pi;
[H,w]=freqz(B,A,n);
subplot(2,1,1)
plot(w,abs(H));
title('Magnitude Vs. Frequency')
subplot(2,1,2)
plot(w,angle(H));
title('Phase Vs. Frequency')
h0=abs(freqz(B,A, [0 pi/2 pi]));
h1=angle(freqz(B,A, [0 pi/2 pi]));
%% 9.6.2
% Define coefficients
A = [1 1.25 0.75]; % Coefficients for y[n]
B = [2 1]; % Coefficients for x[n]
% Compute frequency response with 1024 points
[H, w] = freqz(B, A, 1024);
% Find indices for specific frequencies
index_0 = find(w == 0); % H(j0)
index_pi_over_4 = find(w == pi/2); % H(jπ/4)
index_pi = find(w == pi); % H(jπ)
% Display computed values
disp(['H(j0) = ', num2str(H(index_0))]);
disp(['H(jπ/2) = ', num2str(H(index_pi_over_4))]);
disp(['H(jπ) = ', num2str(H(index_pi))])
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team