필터 지우기
필터 지우기

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 CenterFile Exchange에서 Frequency Transformations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by