Inverse of filter function
51 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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>
0 Commenti
Risposta accettata
Christoph F.
il 2 Mag 2017
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 Commento
Paul
il 15 Gen 2024
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)
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
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)
Più risposte (1)
Jan
il 2 Mag 2017
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 Commenti
John D'Errico
il 5 Mag 2017
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
il 15 Gen 2024
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]
Vedere anche
Categorie
Scopri di più su Frequency Transformations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!