Finding inverse Laplace Transforms using Matlab

조회 수: 7 (최근 30일)
Alicia Stier
Alicia Stier 2019년 2월 12일
댓글: Star Strider 2019년 2월 13일
Does anyone know how to get the inverse laplace transform in MATLAB? Ideally entering the Laplace form of the equation, and getting the output in the time domain.
Thanks!!
P.S. if you have an example you're willing to share that would be appreciated!

채택된 답변

Star Strider
Star Strider 2019년 2월 12일
A reasonably illustrative example:
syms H(s) s t
H(s) = (s^2 + 3*s + 5)/(s^3 + 5*s^2 +6*s + 9);
Hpf = partfrac(H)
h(t) = vpa(ilaplace(Hpf,s,t))
hfcn = matlabFunction(h)
producing:
h(t) =
0.6241318855835944579323146742924*exp(-4.0690229960401146971234049368325*t) + 0.3758681144164055420676853257076*exp(-0.46548850197994265143829753158373*t)*cos(1.4124990678323177947660216914026*t) + 0.50589008998062620975227487302694*exp(-0.46548850197994265143829753158373*t)*sin(1.4124990678323177947660216914026*t)
and (after a bit of editing):
hfcn = @(t)exp(t.*-4.069022996040115).*6.241318855835945e-1+exp(t.*-4.654885019799427e-1).*cos(t.*1.412499067832318).*3.758681144164055e-1+exp(t.*-4.654885019799427e-1).*sin(t.*1.412499067832318).*5.058900899806262e-1
Using the partfrac (partial fraction decomposition) function is frequently necessary. You can use the vpa function to simplify expressions that cannot easily be simplified using the simplify and related functions. The matlabFunction function will convert the expressions into executable numeric (as opposed to symbolic) code.
If you are using the Symbolic Math Toolbox to work with control systems, use the sym2poly function to export your symbolic polynomial coefficients to create transfer functions with the other Toolboxes.
  댓글 수: 2
Alicia Stier
Alicia Stier 2019년 2월 13일
Star Strider,
Thank you so much for your help! I do have quick query about your example's code. Is there a way to have MATLAB put h(t) in a neater form?
Hpf = partfrac(H)
h(t) = vpa(ilaplace(Hpf,s,t))
hfcn = matlabFunction(h)
Star Strider
Star Strider 2019년 2월 13일
Not really.
I experimented with setting the vpa resolution to 5 (so a 5-digit display while retaining full internal precison), however that appears not to be possible, largely because of the transcendental function arguments that, along with exponents, are always displayed at full precision.
This will provide a bit of simplification:
syms H(s) s t
H(s) = (s^2 + 3*s + 5)/(s^3 + 5*s^2 +6*s + 9);
Hpf = partfrac(H);
h(t) = vpa(ilaplace(Hpf,s,t));
h(t) = collect(h(t), 'exp')
hfcn = matlabFunction(h);
producing (with the collect call):
h(t) =
0.6241318855835944579323146742924*exp(-4.0690229960401146971234049368325*t) + (0.3758681144164055420676853257076*cos(1.4124990678323177947660216914026*t) + 0.50589008998062620975227487302694*sin(1.4124990678323177947660216914026*t))*exp(-0.46548850197994265143829753158373*t)
That’s as likely as good as it gets. If you do not use the vpa function, the decimal fractions will instead be long fractions that are difficult to interpret.
If you want a numerical time-domain solution, I would use the ‘hfcn’ output and be done with it. You are certainly free to experiment yourself to see if your inverse Laplace results are more tractable. They may be. My code is simply an illustration.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by