add zeroPole.m to ceuurent folder
This commit is contained in:
parent
9d349a8d80
commit
5ba653331e
5
main.m
5
main.m
|
|
@ -22,4 +22,9 @@ plotRawSignal(X, Fs);
|
||||||
% ==== Analyze frequency spectrum ====
|
% ==== Analyze frequency spectrum ====
|
||||||
[f, power] = frequencySpectrum(X, Fs, 1); % set 1 to plot
|
[f, power] = frequencySpectrum(X, Fs, 1); % set 1 to plot
|
||||||
|
|
||||||
|
% ======== Apply a bandpass filter ==============
|
||||||
|
[filteredSignal, Z, P] = iirFilter(6, [5 20], X, 200, 1); % Butterworth bandpass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
function [Z,P] = zeroPole(b,a,plt)
|
||||||
|
|
||||||
|
%{
|
||||||
|
function [Z,P] = zeroPoles(b,a,plt)
|
||||||
|
Ex: [Z,P] = zeroPoles([1 0.5 -1],[1 0 0.81],1)
|
||||||
|
|
||||||
|
Task: To compute the zeros and poles of a transfer function
|
||||||
|
|
||||||
|
Inputs:
|
||||||
|
-a: vector of a_i (denominator)
|
||||||
|
-b: vector of b_i (numerator)
|
||||||
|
-plt: plot if greater than 0
|
||||||
|
|
||||||
|
Outputs:
|
||||||
|
-Z: zeros (roots of the numerator)
|
||||||
|
-P: poles (roots of the denominator)
|
||||||
|
|
||||||
|
Author: Tikea TE
|
||||||
|
Date: 15/04/2025
|
||||||
|
%}
|
||||||
|
|
||||||
|
% ======== calculate the zeros =========
|
||||||
|
Z = roots(b);
|
||||||
|
% ======== calculate the poles =========
|
||||||
|
P = roots(a);
|
||||||
|
|
||||||
|
if(plt)
|
||||||
|
figure;
|
||||||
|
zplane(Z,P);
|
||||||
|
title("zeros and poles of H(z) in the complex plane");
|
||||||
|
xlabel("Real part");
|
||||||
|
ylabel("imaginary part");
|
||||||
|
legend("zeros","poles");
|
||||||
|
grid on;
|
||||||
|
|
||||||
|
figure;
|
||||||
|
impz(b,a);
|
||||||
|
title("Impulse response");
|
||||||
|
xlabel("samples (n)");
|
||||||
|
ylabel("amplitude of the output y")
|
||||||
|
grid on;
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
Loading…
Reference in New Issue