# What is the physical interpretation of sos in Zp2sos function?

3 ビュー (過去 30 日間)
Andi 2022 年 11 月 17 日

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

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

### 回答 (2 件)

Amey Waghmare 2022 年 11 月 23 日
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: 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.
Hope this resolves the issue.
##### 0 件のコメント表示 -1 件の古いコメント非表示 -1 件の古いコメント

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

Paul 2022 年 11 月 23 日
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).')
ans = 1×12
0.8662 0.8662 0.8985 0.8985 0.9613 0.9613 0.9823 0.9823 0.9893 0.9893 0.9965 0.9965
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)).')
ans = 1×12
0.8655 0.8655 0.8988 0.8988 0.9336 0.9336 0.9614 0.9614 1.0019 1.0019 1.0358 1.0358
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{:})).')
ans = 1×12
0.8662 0.8662 0.8985 0.8985 0.9613 0.9613 0.9823 0.9823 0.9893 0.9893 0.9965 0.9965
Do filtfilt with both forms, observe very different results
rng(101)
x = rand(1000,1);
y1 = filtfilt(b,a,x);
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 3.181425e-17.
y2 = filtfilt(sos,g,x);
plot(y1) plot(y2) Note that filter, which is not part of the signal processing toolbox, does not accept the sos form.

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

### カテゴリ

Find more on Digital Filtering in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!