MATLAB: How to get a inverse laplace of a tf

ilaplacelaplacetf

Hello, I need to find the inverse laplace of a generic tf. How could I do It in an easy way?
close all
clc
num = input('Insira o Polinomio do Numerador: ');
[3 7] % for example

den = input('Insira o Polinomio do Denominador: ');
[1 2 5] % for example
%function [z,p] = (num,den)
z= roots(num)
p= roots(den)
FT = tf(num,den)
h = zpk(num,den,1)
How Can I use the ilaplace function now? thanks

Best Answer

You can derive inverse Laplace transforms with the Symbolic Math Toolbox. It will first be necessary to convert the ‘num’ and ‘den’ vectors to their symbolic equivalents. (You may first need to use the partfrac function to do a partial fraction expansion on the transfer function expressed as a symbolic fraction. That step is not necessary in R2018a.) Then use the ilaplace function. After that, use the simplify and collect functions to produce a compact result:
num = [3 7];
den = [1 2 5];
FT = tf(num,den); % Transfer Function Object
syms s t % Invoke Symbolic Math Toolbox
snum = poly2sym(num, s) % Symbolic Numerator Polynomial
sden = poly2sym(den, s) % Symbolic Denominator Polynomial
FT_time_domain = ilaplace(snum/sden) % Inverse Laplace Transform
FT_time_domain = simplify(FT_time_domain, 'Steps',10) % Simplify To Get Nice Result
FT_time_domain = collect(FT_time_domain, exp(-t)) % Optional Further Factorization
producing:
FT_time_domain =
(3*cos(2*t) + 2*sin(2*t))*exp(-t)
Note that if you want only the time-domain impulse (or step) response of your system, you can get those directly with the impulse and step functions with your ‘FT’ system. It is not necessary to get an analytic expression of your transfer function object first, in that instance.