how to solve this differential equations with dsolve

5 次查看(过去 30 天)
how do i solve this equations with dsolve? And how must be the syntax into the inline code so i can plot them in the end?
2*y''+3x^2*y=exp(2*x) y(1)=3 , y'(2)=0
y''-3*x^2*y=1/x y(1)=3 , y'(2)=-1

回答(1 个)

Ronit
Ronit 2024-8-16
Hello,
To solve differential equations using dsolve in MATLAB, you need to set up the equations and initial conditions properly. Here's how you can solve the given equations:
syms y(x)
Dy = diff(y, x);
D2y = diff(y, x, 2);
% First differential equation
eq1 = 2*D2y + 3*x^2*y == exp(2*x);
cond1 = [y(1) == 3, subs(Dy, x, 2) == 0];
sol1 = dsolve(eq1, cond1);
% Second differential equation
eq2 = D2y - 3*x^2*y == 1/x;
cond2 = [y(1) == 3, subs(Dy, x, 2) == -1];
sol2 = dsolve(eq2, cond2);
This kind of equations involves an integral that is difficult to evaluate numerically. So, the solution contains complex expressions or when the integrals do not converge easily. I suggest you try a different approach by using numerical solvers like ode45 to solve the differential equations instead of relying on dsolve. This approach involves converting the problem to initial value problems and using numerical methods to solve them. And you can usedeval function in MATLAB to evaluate the solution ode45solver.
Please find the following documentation links for more information:
  1. ode45: https://www.mathworks.com/help/matlab/ref/ode45.html
  2. deval: https://www.mathworks.com/help/matlab/ref/deval.html
  3. dsolve: https://www.mathworks.com/help/symbolic/dsolve.html
Hope it helps!

类别

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