Can someone help me "Error using sym/diff"

조회 수: 6 (최근 30일)
Kwok Tim So
Kwok Tim So 2021년 9월 10일
답변: Dyuman Joshi 2021년 9월 10일
Can someone help me with this please!
My question :
and I stuck here:
Thank you so much !!

답변 (2개)

Dyuman Joshi
Dyuman Joshi 2021년 9월 10일
1) Your approach of declaring syms variable and taking x from -pi to pi as initial condition for using dsolve is incorrect .
2) Since, your question asks to verify (meaning you don't need to solve the equation) numerically, you can do something like this.
syms x y
y = sin(x) + 2*cos(x);
z = diff(y,2) + y
z = 
0
As you can see that, the value of differential equation is 0 for any value of x.

Walter Roberson
Walter Roberson 2021년 9월 10일
Your approach is wrong for the question. It asks for numeric verification.
So take x = linspace() a range notably wider than [-pi, pi] because you need several periods in order to verify periodic behaviour.
Then evaluate y = sin(x) + 2*cos(x) for that numeric x.
Now, do numeric differentiation,
dy = gradient(x, y);
d2y = gradient(x, dy);
and compare d2y + dy to 0

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by