- 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 次查看(过去 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
0 个评论
回答(1 个)
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 use ‘deval’ function in MATLAB to evaluate the solution ‘ode45’ solver.
Please find the following documentation links for more information:
Hope it helps!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!