Solving a 2nd order ODE in MATLAB

In summary, the conversation discusses solving a second-order differential equation using the state-variable model and ode45 method in MATLAB. The equation represents a harmonic oscillator and the goal is to find when it is overdamped, underdamped, and critically damped. The speaker suggests using a matrix Z and assigning variables z1 and z2 to represent x and dx/dt, respectively. The matrix Z_dot can then be used to find the solution using the ode45 method in MATLAB. A video tutorial is also mentioned for additional help.
  • #1
patso29
3
0
So I've been trying to figure this out for a while now and all my attempts have failed, like I tried using the command ODE45 but it did not work...

this is the equation -> m(d^2x/dt^2) = −kx − β(dx/dt)
I'm given that 2λ = β/m, and and ω^2 = k/m
and I must solve for when λ^2 − ω^2 > 0
I just can't for the life of me figure out how to do this in MATLAB,
hellp is much appreciated!
 
Physics news on Phys.org
  • #2
Do you want the solution or how to find the solution using matlab?

Well, all I can do is give you the solution so
\begin{array}\\m\ddot{x}=-kx-β\dot{x}\Leftrightarrow m\ddot{x}+β\dot{x}+kx=0\\
mr^2+βr+k=0\Leftrightarrow r=\frac{-β\pm \sqrt{β^2-4mk}}{2m}=^{β=2λm}_{k=mω^2}\frac{-2λm\pm \sqrt{4λ^2m^2-4m^2ω^2}}{2m}=\frac{-2λm\pm 2m\sqrt{λ^2-ω^2}}{2m}\Leftrightarrow r=-λ\pm \sqrt{λ^2-ω^2}\\
x(t)=c_1e^{(-λ+ \sqrt{λ^2-ω^2})t}+c_2e^{(-λ- \sqrt{λ^2-ω^2})t}\end{array}

It is the ode for a harmanic oscillator isn't it?
 
Last edited:
  • #3
yah i basically have to find when its overdamped, underdamped and critically damped... but I need to figure out how to do it in MATLAB, like plug it in and everything, do you know how to do that?
 
  • #4
patso29 said:
yah i basically have to find when its overdamped, underdamped and critically damped... but I need to figure out how to do it in MATLAB, like plug it in and everything, do you know how to do that?

Sorry, I don't use MATLAB
 
  • #5
so how would I solve for what values of B give the inital conditions?
 
  • #6
patso29 said:
so how would I solve for what values of B give the inital conditions?

You have B. All you need to find is c_1 and c_2 with the initial condtitions
 
  • #7
You can't put in a 2nd order ODE in MATLAB directly. You have to use the state-variable model to break it into 2 1st-order ODEs and then use ode45 (RK4) method to get it.

Define a matrix Z and use the key z1 = x and z2 = x_dot (or dx/dt in Leibniz notation). Then z1_dot = z2 and z2_dot (d^2x/dt^2) = -k/m *z1 - (beta/m) * z2. The matrix Z_dot is the derivative of the matrix and has z1_dot and z2_dot as entries. You can then say that Z_dot = A*Z, where A is the matrix of your coefficients. Make a function that computes this 1st order ODE (using matrices as variables) and put it into ode45.

I forget how MATLAB likes its ode45 syntax, but that's the basics.
 
Last edited:

What is a 2nd order ODE?

A 2nd order ODE (ordinary differential equation) is a mathematical equation that involves a function and its derivatives up to the second order. It is commonly used to model physical phenomena in fields such as physics, engineering, and biology.

Why is it important to solve 2nd order ODEs?

Solving 2nd order ODEs allows us to understand and predict the behavior of systems or processes described by these equations. It also allows us to make informed decisions and optimize designs in various fields of science and engineering.

How can MATLAB help solve 2nd order ODEs?

MATLAB has built-in functions and tools specifically designed to solve 2nd order ODEs. These include the "ode45" function, which uses an efficient numerical method to approximate the solution, and the "dsolve" function, which can find exact solutions for some types of 2nd order ODEs.

What are the steps to solve a 2nd order ODE in MATLAB?

The general steps to solving a 2nd order ODE in MATLAB include defining the equation, specifying initial conditions, choosing a solver, and analyzing the results. The specific steps may vary depending on the type of ODE and the desired solution.

What are some common challenges when solving 2nd order ODEs in MATLAB?

Some common challenges when solving 2nd order ODEs in MATLAB include selecting an appropriate solver, dealing with numerical errors, and understanding the limitations of the solution. It is important to carefully choose the solver and verify the results to ensure accuracy and avoid incorrect conclusions.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • Differential Equations
Replies
7
Views
2K
Back
Top