Change symbolic to transfer function in Matlab

Ming Sun

Ming Sun / December 25, 2022

1 min read––– views

syms2tf.m
%% 
% Convert symbolic transfer function to ZPK transfer function
% Ex: Gs = syms2tf(G)
% where G is a symbolic equation and Gs is a zpk transfer function

%%
% function
function [result] = syms2tf(G)
    [symNum, symDen] = numden(G);   % get num and den of symbolic TF
    TFnum = sym2poly(symNum);       % converter symbolic num to polynomial
    TFden = sym2poly(symDen);       % converter symbolic den to polynomial
    result = tf(TFnum, TFden);
test.m
clc; clear; close all;

syms s H

H = 1/(1+s/1e3)

H = syms2tf(H)

bodeplot(H);
grid on;
Bode plot of s-domain transfer function H
Fig. 1Bode plot of s-domain transfer function H

References and materials

[1] Syms to TF Conversion


HomeWikis
SnippetsAbout
Google ScholarLinkedIn