Why is dsolve returning an arbitrary constant?

4 ビュー (過去 30 日間)
David Winthrop
David Winthrop 2019 年 11 月 25 日
編集済み: David Goodmanson 2019 年 11 月 25 日
I have the following differential equation I want to solve from a simple harmonic motion problem.
diffeq.png
When I enter this into MATLAB including two initial conditions, I get an arbitrary constant even though there should not be one. Why?
>> syms y(t) g L c
S = dsolve(diff(diff(y(t))) -L*y - g == 0, y(0) == c,diff(y(0))== 0)
S =
exp(-L^(1/2)*t)*(c - C5 + g/L) - g/L + C5*exp(L^(1/2)*t)

採用された回答

David Goodmanson
David Goodmanson 2019 年 11 月 25 日
編集済み: David Goodmanson 2019 年 11 月 25 日
Hi David,
you need slightly different syntax.
syms y(t) g L c
Dy = diff(y)
S = dsolve(diff(diff(y(t))) -L*y - g == 0, y(0) == c,Dy(0)== 0)
S =
(exp(L^(1/2)*t)*(g + L*c))/(2*L) - g/L + (exp(-L^(1/2)*t)*(g + L*c))/(2*L)
Also, assuming k/m = w0^2 is positive as usual, then for harmonic motion the sign of the k/m term needs to change.
syms y(t) g c w0
Dy = diff(y)
S = dsolve(diff(diff(y(t))) +w0^2*y - g == 0, y(0) == c,Dy(0)== 0)
S =
g/w0^2 - (exp(-t*w0*1i)*(- c*w0^2 + g))/(2*w0^2) - (exp(t*w0*1i)*(- c*w0^2 + g))/(2*w0^2)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by