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 CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by