Matlab- expressing derivatives in an equation with ode45?

Click For Summary
SUMMARY

The discussion focuses on solving a differential equation using MATLAB's dsolve and ode45 functions. The user successfully utilized dsolve to obtain a solution but encountered issues when attempting to implement ode45 due to improper function naming and syntax errors. The professor recommended using inline functions, though the user noted that this is outdated according to MathWorks. The key takeaway is that ode45 requires a proper function handle to evaluate the differential equation correctly.

PREREQUISITES
  • Familiarity with MATLAB syntax and functions
  • Understanding of differential equations and their solutions
  • Knowledge of MATLAB's dsolve function for symbolic solutions
  • Experience with MATLAB's ode45 function for numerical solutions
NEXT STEPS
  • Learn how to create function handles in MATLAB for use with ode45
  • Explore the differences between dsolve and numerical solvers like ode45
  • Investigate the use of anonymous functions in MATLAB for differential equations
  • Review MATLAB documentation on solving differential equations for best practices
USEFUL FOR

Students and educators in mathematics or engineering fields, MATLAB users seeking to solve differential equations, and anyone looking to enhance their understanding of numerical methods in MATLAB.

Dsab123
Messages
2
Reaction score
0

Homework Statement



(-1)^4*xdx + (8y-y^2-13)dy=0; y(0)=4;
1. Use dsolve to obtain a solution.
2. As dsolve was not much help fi nd an implicit solution of the form
f(x, y) = 4

Homework Equations



---

The Attempt at a Solution



the dsolve part was easy, i just did:

syms x y t
dsolve('(-1^4)*x*Dx+(8*y-y^3-13)*Dy=0', 'y(0)=4')
and got a huge matrix-type answer.

So now, I'm having some trouble with 2. My prof told us to use ode45, and this is what I'm thinking:

Z='(-1^4)*x*Dx+(8*y-y^3-13)*Dy=0'
[x,y]=ode45(Z, -10:10, 4)

but I'm getting some errors that its not a proper function name, and some stuff with feval.
Is the problem with the Dy and Dx? My prof suggested using inline, but i read that its older syntax that doesn't really help much, according to mathworks :/

Any suggestions? thanks!
 
Physics news on Phys.org
ode45 (and all the other FD solvers in matlab) need you to provide it with a function that evaluates the differential equation at a given point. For example, check out function handles.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
5
Views
6K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 1 ·
Replies
1
Views
10K