Designing butterworth filter of Nth order

Click For Summary
The discussion focuses on designing a digital Butterworth lowpass filter of nth order, emphasizing user-defined parameters for filter order and cutoff frequency. The user has a basic first-order lowpass filter implemented and seeks to extend their library to include Butterworth filters using minimal MATLAB commands. They are exploring how to incorporate the damping ratio as the filter order increases and are considering methods to derive the filter in hand before coding. The user discusses the conversion of zeros and poles to state space and the challenges faced when applying the cutoff frequency correctly. They reference MATLAB functions like butter and lp2lp for guidance but are uncertain about the appropriate format for the cutoff frequency input.
Xatax
Messages
1
Reaction score
0
I want to design a digital butterworth lowpass filter of nth order, with only freedom of choice to user being order of the filter and the cut off frequency, i already have a 1st order low pass.

Code:​
Code:
T = 1/(2*pi*this.fc);
            this.A = -1/T;
            this.B = 1/T;
            this.C = 1;
            this.D = 0;



This is a very basic lowpass PT1 filter, i take the state space matrix, descrtize it and apply it to my signal. now i want to extend my library to butterworth. I am trying to use as many minimal MATLAB commands as possible. So i thought it's better to derive in hand before implementing it. i wanted to know how to deal with damping ratio as the order is progressed.

When i was searching for answer, i came across wiki of butter worth filter:
Untitled.png


I can just hard code this, but have they considered damping ratio and how do i covert this to state space.Or, i found another way, where i find zeros and poles based on the order of the filter.
Code:
% Poles are on the unit circle in the left-half plane.
n = varargin{1} % order of the filter
fc = varargin{2} % cut off frequency
Wn = (fc*2)/Fs % Fs is sampling frequency, normalizing the cut off frequency
z = [];
p = exp(1i*(pi*(1:2:n-1)/(2*n) + pi/2)); %n is the order of the filter
p = [p; conj(p)];
k = real(prod(-p)); %product of an array element´

%When we get zpk, we just convert them to state space.

[a,b,c,d] = zp2ss(z,p,k);

%Now transforming the abcd matrix to the given cut off frequency
[a,b,c,d] = lp2lp(a,b,c,d,Wn);

The only problem is while applying the cut off frequency, '[a,b,c,d] = lp2lp(a,b,c,d,Wn);' should apply normalized one or in rads/sec or just in Hz. Even though i tried all of them still would like i to ask where i am going wrong
 
I am trying to understand how transferring electric from the powerplant to my house is more effective using high voltage. The suggested explanation that the current is equal to the power supply divided by the voltage, and hence higher voltage leads to lower current and as a result to a lower power loss on the conductives is very confusing me. I know that the current is determined by the voltage and the resistance, and not by a power capability - which defines a limit to the allowable...

Similar threads

Replies
8
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 20 ·
Replies
20
Views
2K
Replies
14
Views
3K
Replies
6
Views
2K
  • · Replies 15 ·
Replies
15
Views
9K
  • · Replies 29 ·
Replies
29
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
2
Views
6K
  • · Replies 1 ·
Replies
1
Views
3K