Change symbolic to transfer function in Matlab
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;
Fig. 1Bode plot of s-domain transfer function H