필터 지우기
필터 지우기

Using ilaplace function i get answer in terms of ilaplace but i need it in terms of a variable t:

조회 수: 7 (최근 30일)
This is my code:
clc;
clear;
syms t y(t) s Y
Dy=diff(y,t); D2y=diff(Dy,t);
F=input("Enter coefficients of [y'' y' y]");
a=F(1);b=F(2);c=F(3);
nh=input('Enter the RHS function f(t)');
eqn=a*D2y+b*Dy+c*y-nh;
LTY=laplace(eqn,t,s);
IC=input("enter initial conditions [y0,y0']");
y0=IC(1);dy0=IC(2);
LTY=subs(LTY,laplace(y(t),t,s),Y);
LTY=subs(LTY,y(0),y0);
LTY=subs(LTY,subs(diff(y(t),t),t,0),dy0);
YS=solve(LTY,Y);
y=ilaplace(YS,s,t)
And when i enter the input:
[1 0 1]
3*(1-heaviside(t-4))+(2*t-5)*heaviside(t-4)
[1,0]
I get the output as
y =
2*ilaplace(1/(s^2*exp(4*s) + s^4*exp(4*s)), s, t) - 2*cos(t) + 3
how to get replace ilaplace in the answer with actual answer as function of t?

채택된 답변

Shivansh
Shivansh 2022년 10월 4일
This can be resolved by using simplify function in the penultimate line of your code (line 16 in attached screenshot).
Below is a link to the documentation for the "simplify" function:
After using simplify function you will get output as
This problem can arise when there is there is presence of function which is not integrable in closed form. For example- "exp(-x^2)" is not integrable in closed form. If the expression cannot be simplified further, it will give output in term of ilaplace only.
However In some cases , when "ilaplace" returns a function of "ilaplace" as part of the output, calling "simplify" before passing the function to "ilaplace" leads to a closed-form solution.
This can be understood better by using the following example. If we execute the following line in Matlab.
syms s
ilaplace((exp(pi*s) + 1)/((exp(pi*s) + s^2*exp(pi*s))*(s^2 + s + 5/4)))
we will get result as-
ilaplace(exp(pi*s)/((exp(pi*s) + s^2*exp(pi*s))*(s^2 + s + 5/4)), s, t) +
ilaplace(1/((exp(pi*s) + s^2*exp(pi*s))*(s^2 + s + 5/4)), s, t)
If, however, one factors "exp(pi*s)" out of the numerator and denominator, one will get output as:
syms s
ilaplace(1/((s^2 + 1)*(s^2 + s + 5/4)) + exp(-pi*s)/((s^2 + 1)*(s^2 + s + 5/4)))
This returns:
(4*sin(t))/17 - (16*cos(t))/17 + (16*exp(-t/2)*(cos(t) + sin(t)/4))/17 -
heaviside(t - pi)*((4*sin(t))/17 - (16*cos(t))/17 + (16*exp(pi/2 - t/2)*(cos(t) + sin(t)/4))/17)
which is a closed-form solution.
Similarly, if one calls:
syms s
ilaplace(simplify((exp(pi*s) + 1)/((exp(pi*s) + s^2*exp(pi*s))*(s^2 + s + 5/4))))
This returns:
(4*sin(t))/17 - (16*cos(t))/17 + (16*exp(-t/2)*(cos(t) + sin(t)/4))/17 -
4*heaviside(t - pi)*(sin(t)/17 - (4*cos(t))/17 + (4*exp(pi/2 - t/2)*(cos(t) + sin(t)/4))/17)
Which is the same output after factoring out "exp(pi*s)"(after simplification).

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by