MATLAB Answers

HOW TO GET THE VALUES OF CONSTANTS

9 views (last 30 days)
MAYANK MALHOTRA
MAYANK MALHOTRA on 16 Apr 2021
Answered: John D'Errico on 16 Apr 2021
syms y(x)
pi=3.14;
ode = diff(y,x,2) == 0;
ySol(x) = dsolve(ode)
THE ANSWER COOMING IS ySol(x) =
C2 + C1*x
IF I HAVE CONDITIONS
ysol(0)=0 and ySol(pi)=0 how to get the values of c1 and c2

Answers (1)

John D'Errico
John D'Errico on 16 Apr 2021
Please don't YELL!
Next, NEVER define pi. pi already exists, and I hate to tell you, it ain't 3.14. That only happens in certain places I won't name. In MATLAB, pi is already defined, far more accurately than that.
format long g
pi
ans =
3.14159265358979
syms y(x)
ode = diff(y,x,2) == 0;
ySol(x) = dsolve(ode,y(0) == 0,y(pi) == 0)
ySol(x) = 
0
Which is what you would expect, since if we have the ODE with no boundary conditions at all,
y'' == 0
the general solution is as you found, a linear polynomial. If that polynomial must then be zero at two points, then the polynomial reduces to the constant value 0.

Community Treasure Hunt

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

Start Hunting!

Translated by