How find symbolic solution matlab

I am trying to solve this simple autonomous differential equation using the dsolve function but MATLAB cannot find a symbolic solution to the function. Does anyone have any idea how I could solve the problem? The code is the following:
clc, clear all
syms y(t)
eqn = diff(y,t,2) == -9.8*sin(y) - 0.5*y'
Dy = diff(y,t)
cond = [y(0)==0.8, Dy(0)==0.8]
ySol(t) = dsolve(eqn,cond)
Thanks in advance to anyone who can help me.

4 件のコメント

Stephan
Stephan 2020 年 11 月 23 日
編集済み: Stephan 2020 年 11 月 23 日
Sure about:
sin(y)
or did you mean:
sin(t)
Also does:
0.5*y'
mean the first derivative or the transpose of y - like Matlab will interpret this?
Juan Saa
Juan Saa 2020 年 11 月 23 日
it's:
sin(y)
Because t is a sym var. And:
0.5*y'
Is the first derivative, wich i was also trying to declareas:
Dy = diff(y,t)
But it throws me the same warning, that MATLAB cannot find a symbolic solution.
John D'Errico
John D'Errico 2020 年 11 月 23 日
It cannot find a symbolic solution because one apparently does not exist. And that is why Stephan was asking if you really intended sin(t), not sin(y), as there may well be a solution in that case.
Juan Saa
Juan Saa 2020 年 11 月 23 日
I understand, thanks for your help

サインインしてコメントする。

回答 (1 件)

Stephan
Stephan 2020 年 11 月 23 日

1 投票

It appears that there either is no symbolic solution or Matlab is not powerful enough to find one. For sin(t) it would work. However Wolfram Alpha also does not provide an analytical solution for this ode - here is the numeric approach:
syms y(t)
Dy = diff(y,t)
eqn = diff(y,t,2) == -9.8*sin(y) - 0.5*Dy
% make numeric function from symbolic
[V,S] = odeToVectorField(eqn)
fun = matlabFunction(V,'Vars',{'t','Y'})
% solve ode numeric
[t,y] = ode45(fun,[0 10],[0.8, 0.8]);
plot(t,y)

2 件のコメント

Juan Saa
Juan Saa 2020 年 11 月 23 日
Exactly, I was also trying it with Wolfram Alpha and can't find a solution. I think it has to do with the differential equation being autonomous.
Juan Saa
Juan Saa 2020 年 11 月 23 日
Thank you very much for your help! :)

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeSymbolic Math Toolbox についてさらに検索

質問済み:

2020 年 11 月 23 日

コメント済み:

2020 年 11 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by