% This function turns a Transfer Function into a symbolic equation
% Created by Brevin Banks 
% Modified 3/7/2023
% Inputs:
%   TF - the transfer function desired to change to symbolic form of tf
%   type
% Outputs:
%   symTF - the output symbolic equation of the desired transfer function

function symTF = Tf2Sym(TF) 

syms s
[num,den] = tfdata(TF); % Grab the numerator and denominator
deneq = 0; %initialize symbolic denominator
%iterativley create denominator
for k = length(den{1}):-1:1
    q = length(den{1})-k+1;
    deneq = deneq + den{1}(q)*s^(k-1);
end
numeq = 0;%initialize symbolic numerator
%iterativley create numerator
for k = length(num{1}):-1:1
    q = length(num{1})-k+1;
    numeq = numeq + num{1}(q)*s^(k-1);
end
%Create the output symbolic transfer function
symTF = vpa(numeq/deneq);
end