how to solve this differential equations with dsolve

5 Ansichten (letzte 30 Tage)
UserG UserG
UserG UserG am 17 Jun. 2021
Beantwortet: Ronit am 16 Aug. 2024
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

Antworten (1)

Ronit
Ronit am 16 Aug. 2024
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!

Community Treasure Hunt

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

Start Hunting!

Translated by