heaviside and sign function
15 ビュー (過去 30 日間)
古いコメントを表示
Dimitrios Adam
2020 年 2 月 9 日
コメント済み: Walter Roberson
2020 年 2 月 9 日
Hello,
i have for example this differential equation
ode = diff(y,x,2)+2*diff(y,x,1)+y==exp(-x)+heaviside(x-2)-dirac(x-2);
cond1 = y(0) == 0;
cond2 = Dy(0) == 0;
Τhe problem is when i solve it the result contains the fucntion sign instead of heaviside:
ySol(x) =
sign(x - 2)/2 + (x^2*exp(-x))/2 + exp(2 - x)*(sign(x - 2) + 1) - x*exp(2 - x)*(sign(x - 2)/2 + 1/2) + 1/2
Do you know how can i change the sign in the result and only have heaviside function?
Thank you
採用された回答
Thiago Henrique Gomes Lobato
2020 年 2 月 9 日
The heavside function is not the same as the sign function, you can't simply change one for another. If you want to write the sign function in terms of a heavside function you can use the following relation:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/270674/image.png)
Where
is the heavside function.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/270675/image.png)
3 件のコメント
Thiago Henrique Gomes Lobato
2020 年 2 月 9 日
編集済み: Thiago Henrique Gomes Lobato
2020 年 2 月 9 日
Yes
syms x
Y = sign(x - 2)/2 + (x^2*exp(-x))/2 + exp(2 - x)*(sign(x - 2) + 1) - x*exp(2 - x)*(sign(x - 2)/2 + 1/2) + 1/2;
Y2 = subs(Y,sign(x-2),2*heaviside(x-2)-1) % Use subs to replace what you want to
subs(Y,5)
subs(Y2,5)
Y2 =
heaviside(x - 2) + 2*heaviside(x - 2)*exp(2 - x) + (x^2*exp(-x))/2 - x*heaviside(x - 2)*exp(2 - x)
ans =
(25*exp(-5))/2 - 3*exp(-3) + 1
ans =
(25*exp(-5))/2 - 3*exp(-3) + 1
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Mathematical Functions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!