![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1204248/image.png)
What is the physical interpretation of sos in Zp2sos function?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi everyone,
I am trying to filtering my signal using the following script.
N=length(t);
dt=(t(end)-t(1))/(N-1); %sampling interval (days)
fs=1/dt; fNyq=fs/2; %sampling frequency, Nyquist frequency (cycles/day)
f1=1; f2=4; %bandpass corner frequencies (cycles/day)
[z,p,k]=butter(4,[f1,f2]/fNyq,'bandpass'); %4th order Butterworth bandpass filter coefficients
[sos,g]=zp2sos(z,p,k); %sos representation of the filter
xde=filtfilt(sos,g,y); %apply zero phase filter to ser1
But, i am still not sure about the physical interpretation of few parameteres.
For example:
[z,p,k] > are poles, zeroes and gain are converted to sos and g. here what exactly sos shows and why we need to do this.
In my case, i get this as sos matrix, but i am not clear how to interpret this
1 2 1 1 -1.9836 0.9838
1 2 1 1 -1.9918 0.9921
1 -2 1 1 -1.9922 0.9922
1 -2 1 1 -1.9979 0.9979
0 Kommentare
Antworten (2)
Amey Waghmare
am 23 Nov. 2022
Hi,
As per my understanding, you have used ‘zp2sos’ to obtain Second order section (sos) representation of the filter, and want to understand the interpretation of the resulting sos matrix.
Please refer to the attached image:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1204248/image.png)
The sos representation is returned as a L-by-6 matrix, where L is the number of sections, which depends upon the number of poles and zeros of the filter. Each rows contains the numerator and denominator coefficients 'bik' and 'aik' of the second order sections of the filter. The structure of the filter is shown by H(z) in the above image.
For more information, please refer to the following documentation on zp2sos: https://in.mathworks.com/help/signal/ref/zp2sos.html
Hope this resolves the issue.
0 Kommentare
Paul
am 23 Nov. 2022
Hi Andi,
Addresing the second part of your question: " why we need to do this"
filtfilt will accept either transfer function (b,a) or sos (sos,g) form of the the filter, but not zpk form. So we have to choose one or the other. sos form has better numerical properties for computation.
Example filter parameters
n = 6;
Wn = [2.5e6 29e6]/500e6;
ftype = 'bandpass';
% Zero-Pole-Gain design
[z,p,k] = butter(n,Wn,ftype);
Note that all of the poles are inside the unit circle, as expected.
sort(abs(p).')
Convert to transfer function form
[b,a] = zp2tf(z,p,k);
Because of floating point issues, some of the poles are now outside the unit circle, which would be an unstable filter.
sort(abs(roots(a)).')
Convert to sos form
[sos,g] = zp2sos(z,p,k);
The poles of the sections are inside the unit circle, and they should be very, very close matches to p.
C = cellfun(@(x) roots(x(4:6).'),mat2cell(sos,ones(size(sos,1),1)),'UniformOutput',false);
sort(abs(vertcat(C{:})).')
Do filtfilt with both forms, observe very different results
rng(101)
x = rand(1000,1);
y1 = filtfilt(b,a,x);
y2 = filtfilt(sos,g,x);
plot(y1)
plot(y2)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Digital Filtering finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!