Clear Filters
Clear Filters

Designing a Nth butterworth filter with plot placement

3 views (last 30 days)
I am trying to design a Nth order continous time Butterworth filter in state space, with pole placement technique.
n = varargin{1}
Fc = this.fc
wc = 2*pi*Fc;
T = 1/(2*pi*Fc);
%----------------Finding Poles--------------------------
p = exp(1i*(pi*(1:2:n-1)/(2*n) + pi/2)); %n is the order of the filter
p = [p; conj(p)];
p = p(:);
if rem(n,2)==1 % n is odd
p = [p; -1];
end
%----------------Finding Filter co efficents---------------
if length(p)<= 2
a = conv([1,-p(1)],[1,-p(2)]);
end
if length(p) > 2
a = conv([1,-p(1)],[1,-p(2)]);
for i = 3: length(p)
a = conv(a,[1,-p(i)]);
end
end
a = real(a)
a = fliplr(a);
%----------------- calculating the matricies%-----------------
%--------------A matrix---------------
N = length(a)-1;% order of the matrix
last_row = (a(1:end-1))*(-1/a(end));% creating the last row
last_row = (wc.^(N:-1:1)).*last_row;% creating the last row
k = ones(1,N-1);
this.x = diag(k,1) ; % diag(vector, k) produce a matrix filled with zero's and k'th off diagonal as vector, in this case, 1's.
this.x(end,:) = last_row;% adding the last_row
%-------------desiging B matrix--------------
this.y = zeros(N,1); % creates a coloumn matrix with zeros
this.y(N,:) = 1/(a(end)*wc^n); % writes last elements as a
%--------------- writing C matrix--------------
this.z = zeros(1,N); %creates a row matrix
this.z(1,1) = 1;
%------------ writing the D matrix----------------
this.u = [0];
I know the code is bit lengthy, but i have tried everything, but can't figure out where i am going wrong. Because I am not getting any error. The resultant output is just 0. The code is pretty simple, I find the poles, then the filter coefficients. With the filter coefficients, i design A,B,C,D Matrices. This is a continuous butterworth filter, Can anyone point the mistake i am doing?

Answers (0)

Community Treasure Hunt

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

Start Hunting!