from
Continous Fractions Expansion
by Mario Coutino
Computes the continous fractions expasion of a pulse transfer function.
|
| cont_frac(num,den) |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Mario Alberto Coutino Minguez %
% %
%[A_VECTOR B_VECTOR] = CONT_FRACT(NUM,DEN) %
% Computes the continuos fraction expansion of a transfer%
% function which numerator and denomitador are [num] and %
% [den] respectively. %
% The coefficients of the expansion are saved in %
% a_vector and b_vector for their further usage. %
% %
% %
%Centro Universitario de Ciencias Exactas e Ingenieras %
%Universidad de Guadalajara 2013 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [a_vector b_vector] = cont_frac(num,den)
l_num = length(num);
l_den = length(den);
coeffs = [];
%Coefficients' Variables
a_vector = [];
b_vector = [];
aux = [];
%Flow Variables
i = 0;
k = 0;
j = 1;
stop = 0;
if (l_num == l_den)
a_vector(1) = num(1) / den(1);
num = num(2:end) - a_vector(1) *den(2:end);
else
if (l_num > l_den)
disp('error');
end
end
while( stop ~= 1)
aux = num;
num = den;
den = aux;
if (mod(i,2) == 0)
b_vector(1+k) = num(1)/den(1);
num = [num(2:end-1) - b_vector(1+k) *den(2:end) num(end)];
k = k+1;
else
a_vector(1+j) = num(1)/den(1);
num = num(2:end) - a_vector(1+j) *den(2:end);
j = j+1;
end
if(num == 1)
stop = 1;
a_vector(1+j) = den;
end
i = i+1;
end
end
|
|
Contact us