- ode45: https://www.mathworks.com/help/matlab/ref/ode45.html
- deval: https://www.mathworks.com/help/matlab/ref/deval.html
- dsolve: https://www.mathworks.com/help/symbolic/dsolve.html
how to solve this differential equations with dsolve
5 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Ronit
on 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 use ‘deval’ function in MATLAB to evaluate the solution ‘ode45’ solver.
Please find the following documentation links for more information:
Hope it helps!
0 Comments
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!