Solving Diff. Equation in MATLAB: Need Help

  • Context: MATLAB 
  • Thread starter Thread starter MJCfromCT
  • Start date Start date
  • Tags Tags
    Matlab
Click For Summary

Discussion Overview

The discussion revolves around solving a differential equation in MATLAB, specifically the equation m*(dV/dt) = F_rho - F_mu + F_g. Participants explore the setup and methods for solving this equation, including the roles of various force terms and potential approaches to numerical solutions.

Discussion Character

  • Technical explanation
  • Homework-related
  • Mathematical reasoning

Main Points Raised

  • One participant expresses uncertainty about how to set up the differential equation in MATLAB and seeks guidance.
  • Another participant suggests that solving the equation in Mathematica would be straightforward using DSolve, questioning whether MATLAB has similar capabilities.
  • A participant provides the specific equations for the forces involved, clarifying that they know the constants for F_rho and F_g, while F_mu depends on V.
  • Further elaboration on the equation's structure is provided, indicating a potential approach to solving it by hand and discussing the linear dependence of V'(t) on V(t).
  • One participant indicates a preference for MATLAB due to lack of access to Mathematica and expresses interest in understanding how changes in variables affect V.
  • A suggestion is made to use the 'ode45' function in MATLAB to set up the differential equation numerically.

Areas of Agreement / Disagreement

Participants generally agree that the differential equation is relatively simple and can be solved, but there is no consensus on the best method to implement the solution in MATLAB, as some prefer symbolic solutions while others focus on numerical approaches.

Contextual Notes

Participants mention various methods for solving the equation, including symbolic and numerical approaches, but do not resolve which method is preferable in the context of MATLAB.

Who May Find This Useful

This discussion may be useful for individuals looking to solve differential equations in MATLAB, particularly those interested in the application of numerical methods like ode45, as well as those exploring the effects of variable changes on solutions.

MJCfromCT
Messages
20
Reaction score
0
Hi everyone,

Its been an incredibly long time since I've had to solve a differential equation in MATLAB, and I was wondering if someone could point me in the right direction. I have the following equation:

m*(dV/dt) = F_rho - F_mu + F_g

the F_rho term includes just constants that I know
the F_mu term depends on V
the F_g term includes constants that I know

I'm pretty clueless as to how to set this up and get started on this, maybe once I get the ball rolling it'll come back to me. :) Any help you could provide is appreciated. Thanks!
 
Physics news on Phys.org
I wouldn't know how to do it in MATLAB, but in Mathematica it would be fairly simple: just plug in the formula and apply DSolve. It will even solve it symbolically (i.e. you don't have to put in the values for the constants --- I don't know if MATLAB does this too).

Do you know the actual formulas for the different forces, or do you just know that [itex]F_\mu[/itex] is some function of V and the other two are some constant?
 
Thanks for the reply,

I have the actual equations for those forces, I just didn't write them out before to save some time. :)

F_rho = 2*pi*r*rho*(cos(theta1)-cos(theta2))

F_mu = 8*pi*mu*l*V + 8*pi*mu_g*(L-l)*V

F_g = pi*sigma*r^2*l*g*sin(phi)

I apologize for the horrible formatting, I'd retype it if I knew the latex syntax.

But yes, basically I know everything in F_rho, I know everything but V in F_mu, and I know everything in F_g.
 
No problem, I'm used to something :)
I'm afraid I still can't help you with solving this in MATLAB, though this equation is sufficiently simple that it can be solved by hand. I'll assume now that you have had some basic differential equations, if not, skip the next part.

We can write it as
[tex]V'(t) = C + \mu V(t)[/tex]
where C is the sum of F_rho and F_g and mu is the thing in front of the V (something like 8 pi (mu l + mu_g (L - l))).
There is a linear dependence (V'(t) ~ V(t)) so you could try V(t) = exp(alpha t) and then see what alpha would have to be, to solve the homogeneous equation m V'(t) = mu V(t).
For the particular solution, m V'(t) = C + mu V(t), you could try a constant, because then the left hand side is zero and you immediately get V_part = - C / mu.
The general solution is the sum of the particular part and the solution to the homogeneous equation, so it will be something like -C/mu + exp(alpha t).

====

In Mathematica, you could solve it by something like
DSolve[m V'[t] == F\[Rho] + Fg + \[Mu] V[t], V[t], t]

And again, I'm not sure if MATLAB, will be able to solve it symbolically (non-numerically).

Whichever method you choose, this is a very basic differential equation and you will probably want to learn how to solve it by hand anyway.

Hope that helps you a bit, though it doesn't really answer your original question (I don't know how tightly bound you are to MATLAB)
 
Thank you for the explanation, CompuChip. Unfortunately, I am pretty tied to MATLAB, as I don't have access to a program like Mathematica, although I will try to get access to it. I'm glad to find out that this is a relatively simple one that should be able to be solved without much difficulty.

In the end, what I'd like to have happen is for me to be able to change some of the variables a bit, and see how V is affected. Eventually I'll make some of those variables time dependent and see how that affects V as well.

Thanks!
 
type 'help ode45' to get started

As it says, basically you set up a function that calculates dV/dt from V and t and go from there. Later you can set numerical options using 'odeset' if you need to.
 

Similar threads

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