Matlab- expressing derivatives in an equation with ode45?

In summary, the conversation is about solving a differential equation using the dsolve and ode45 functions. The first part involves using dsolve to obtain a solution, while the second part involves finding an implicit solution using ode45. The person is having trouble with the second part and is seeking suggestions on how to properly use the ode45 function.
  • #1
Dsab123
2
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
  • #2
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.
 

Related to Matlab- expressing derivatives in an equation with ode45?

1. What is the purpose of expressing derivatives in an equation with ode45?

The purpose of expressing derivatives in an equation with ode45 is to solve differential equations numerically. Ode45 is a function in Matlab that uses a Runge-Kutta method to approximate the solution of a first-order differential equation with a given initial condition.

2. How do you express derivatives in an equation with ode45?

To express derivatives in an equation with ode45, you need to define the derivative function in a separate file or within the same script. The derivative function should take in the independent variable and the dependent variable as inputs and return the value of the derivative at that point.

3. What is the syntax for using ode45 to solve a differential equation?

The syntax for using ode45 to solve a differential equation is [t, y] = ode45(@derivs, tspan, y0), where derivs is the name of the derivative function, tspan is a vector specifying the start and end times, and y0 is the initial value of the dependent variable.

4. Can ode45 handle higher-order derivatives?

Yes, ode45 can handle higher-order derivatives. You just need to rewrite the higher-order differential equation as a system of first-order equations. This can be done by introducing new variables to represent the higher-order derivatives.

5. What are some common errors when using ode45 to solve differential equations?

Some common errors when using ode45 to solve differential equations include not defining the derivative function correctly, using incorrect syntax, and providing inconsistent initial conditions or time spans. It is also important to check for any singularities or discontinuities in the derivative function, as these can cause errors in the numerical solution.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
1
Views
929
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Introductory Physics Homework Help
Replies
5
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
5K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
2K
Back
Top