フィルターのクリア

Inverse of filter function

51 ビュー (過去 30 日間)
azzendix
azzendix 2017 年 5 月 2 日
コメント済み: Paul 2024 年 1 月 15 日
How to write the inverse of the filter function?
I use a filter function with input x to get output y. I want to get input x back.
y = filter(b,a,x,zi)
y = <inverse filter to get original input x>

採用された回答

Christoph F.
Christoph F. 2017 年 5 月 2 日
In the z domain, the transfer function of a filter H(z) is B(z)/A(z).
The inverse of the transfer function is A(z)/B(z). However, this only makes sense if the zeros of B(z) are inside the unit circle; if they are outside, the inverse filter will have poles outside the unit circle and hence be unstable.
  1 件のコメント
Paul
Paul 2024 年 1 月 15 日
In addition to the possiblity of the inverse filter having poles outside the unit circle, which is of practical concern, another consideration is the causality of the inverse filter.
Define the signal
rng(100);
N = 1000;
sig = sin(2*pi*40*(0:N-1)*0.001);
n = 0:N-1;
Define an IIR filter with one zero and four poles and filter the signal
[B,A] = zp2tf(0.6,[0.1 0.2 0.3 0.4],1)
B = 1×5
0 0 0 1.0000 -0.6000
A = 1×5
1.0000 -1.0000 0.3500 -0.0500 0.0024
sigf = filter(B,A,sig);
figure
plot(n,sig,n,sigf)
Attempting to filter with the inverse filter casues an error because the inverse filter is non-causal (more zeros than poles)
try
sigr = filter(A,B,sigf);
catch ME
ME.message
end
ans = 'First denominator filter coefficient must be non-zero.'
Instead, we mutiply the inverse filter by 1/z^3 (the power is the number of leading zeros in B), then filter
sigr = filter(A,B(end-1:end),sigf);
then shift the output back by three samples.
sigr = sigr(4:end);
nr = numel(sigr);
This approach recovered the input signal except for the last three samples.
figure
plot(n,sig,n(1:nr),sigr)
figure
plot(n(1:nr),sig(1:nr)-sigr)

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

その他の回答 (1 件)

Jan
Jan 2017 年 5 月 2 日
This is not possible. Remember that filtering destroys the original information. If you e.g. remove the high frequency noise from a signal, it does not exist in the output anymore. Then there is no way to re-create it.
  8 件のコメント
John D'Errico
John D'Errico 2017 年 5 月 5 日
I think the difference is, suppose you took the mean of your data. Then the original data is not recoverable. But here you have a linear transformation of the data. N points in, N points out. As long as the mapping is not singular, then there is an inverse transformation.
Paul
Paul 2024 年 1 月 15 日
Using the 'same' option with conv is not the same operation as using filter. In this example, the 'same' option results in an output that is shifte by 1 sample relative to the output of filter. Can the A matrix be changed appropriately?
Probably won't change the general conclusion ....
rng(100)
K = ones(1,3)/3;
S0 = rand(1,10);
S1 = conv(S0,K,'same');
S1a = conv(S0,K);
S1b = filter(K,1,S0);
[S1;S1a(1:numel(S0));S1b]
ans = 3×10
0.2739 0.4154 0.5159 0.4247 0.3237 0.2657 0.5394 0.5444 0.5126 0.2373 0.1811 0.2739 0.4154 0.5159 0.4247 0.3237 0.2657 0.5394 0.5444 0.5126 0.1811 0.2739 0.4154 0.5159 0.4247 0.3237 0.2657 0.5394 0.5444 0.5126

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

カテゴリ

Help Center および File ExchangeFrequency Transformations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by