How to filter a signal with a transfer function?

167 ビュー (過去 30 日間)
Ana Gabriela Guedes
Ana Gabriela Guedes 2021 年 5 月 26 日
コメント済み: Star Strider 2021 年 5 月 27 日
Hi!
I have a discrete signal (a vector with many values) I want to filter using a low pass filter but I only have the tranfer function in the form. How can I do this since the common filter functions dont use transforms?

採用された回答

Star Strider
Star Strider 2021 年 5 月 26 日
The easiest approach is to first let the Control System Toolbox solve it, then realise it as a discrete filter using the numerator and denominator vectors —
z = tf('z');
H = (1-z^-6)^2 / (1-z^-1)^2
H = z^14 - 2 z^8 + z^2 -------------------- z^14 - 2 z^13 + z^12 Sample time: unspecified Discrete-time transfer function.
Num = H.Numerator
Num = 1×1 cell array
{[1 0 0 0 0 0 -2 0 0 0 0 0 1 0 0]}
Den = H.Denominator
Den = 1×1 cell array
{[1 -2 1 0 0 0 0 0 0 0 0 0 0 0 0]}
figure
freqz(Num{:}, Den{:}, 2^16)
Use ‘Num{:}’ and ‘Den{:}’ with filtfilt to filter the signal.
Remember that it will be necessary to define a sampling interval, ‘Ts’ where ‘Ts=1/Fs’ where ‘Fs’ is the sampling frequency.
.
  2 件のコメント
Ana Gabriela Guedes
Ana Gabriela Guedes 2021 年 5 月 26 日
編集済み: Ana Gabriela Guedes 2021 年 5 月 27 日
Thank you! Where sould I insert de sampling interval?
I'm getting the error that filtfilt arguments should me double matrices and I only have row vectors
Star Strider
Star Strider 2021 年 5 月 27 日
No, use the filtfilt function to filter ‘x’.
Assuming that the sampling interval or sampling frequency is defined in the first tf call:
Fs = 1000; % Define Sampling Frequency
Ts = 1/Fs;
z = tf('z',Ts);
H = (1-z^-6)^2 / (1-z^-1)^2
H = z^14 - 2 z^8 + z^2 -------------------- z^14 - 2 z^13 + z^12 Sample time: 0.001 seconds Discrete-time transfer function.
Num = H.Numerator
Num = 1×1 cell array
{[1 0 0 0 0 0 -2 0 0 0 0 0 1 0 0]}
Den = H.Denominator
Den = 1×1 cell array
{[1 -2 1 0 0 0 0 0 0 0 0 0 0 0 0]}
figure
freqz(Num{:}, Den{:}, 2^16, Fs)
x = [-233....-667]
x_filtered = filtfilt(Num{:}, Den{:}, x)
and go from there.
.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDigital Filtering についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by