0% found this document useful (0 votes)
140 views1 page

Convert Sym 2 TF

This function takes in a transfer function as an input and converts it into a numerator polynomial, denominator polynomial, and transfer function object. It first checks if the input is numeric or symbolic. For symbolic inputs, it extracts the numerator and denominator polynomials, finds the poles and zeros, and constructs the numerator and denominator polynomials by convolving the factored forms. Finally, it returns the transfer function object constructed from the numerator and denominator polynomials.

Uploaded by

Siladittya Manna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
140 views1 page

Convert Sym 2 TF

This function takes in a transfer function as an input and converts it into a numerator polynomial, denominator polynomial, and transfer function object. It first checks if the input is numeric or symbolic. For symbolic inputs, it extracts the numerator and denominator polynomials, finds the poles and zeros, and constructs the numerator and denominator polynomials by convolving the factored forms. Finally, it returns the transfer function object constructed from the numerator and denominator polynomials.

Uploaded by

Siladittya Manna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

%Declare "syms s" before running the function and enter the TF in terms of "s"

function [TF,NumPoly,DenPoly] = convert2tf(inputTF)

NumPoly = 1;
DenPoly = 1;
if isnumeric(inputTF)~=0
TF = tf(NumPoly,DenPoly);
else
[No,Do]=numden(inputTF);
PDo = solve(Do);
n=str2num(char(No));
if isequal(n,[])
ZNo = solve(No);
end
Poles = [];%zeros(1,length(PDo));
Zeros = [];%zeros(1,length(ZDo));
for i=1:length(PDo)
Poles(i)=str2num(char(PDo(i)));
end

DenFac = [];
for i=1:length(Poles)
DenFac(i,:)=[1,-Poles(i)];
end

for i=1:length(Poles)
DenPoly = conv(DenPoly,DenFac(i,:));
end

if isequal(n,[])
for i=1:length(ZNo)
Zeros(i)=str2num(char(ZNo(i)));
end
%plot(real(Zeros),imag(Zeros),'go','LineWidth',2,'MarkerSize',8);
NumFac = [];
for i=1:length(Zeros)
NumFac(i,:)=[1,-Zeros(i)];
end
for i=1:length(Zeros)
NumPoly = conv(NumPoly,NumFac(i,:));
end
end

TF = tf(NumPoly, DenPoly)
end

You might also like