MATLAB Solving Diff. Equation in MATLAB: Need Help

  • Thread starter Thread starter MJCfromCT
  • Start date Start date
  • Tags Tags
    Matlab
AI Thread Summary
The discussion focuses on solving a differential equation in MATLAB, specifically m*(dV/dt) = F_rho - F_mu + F_g, where F_rho, F_mu, and F_g are defined in terms of known constants and the variable V. The user seeks guidance on setting up the equation in MATLAB, as they are more familiar with Mathematica's DSolve function. It is noted that the equation can be approached by hand, and a general solution can be derived involving both particular and homogeneous solutions. The conversation emphasizes the importance of learning to solve such equations manually, even as the user expresses a need for MATLAB-specific methods. Ultimately, the user aims to manipulate variables to observe their effects on V over time.
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 F_\mu 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
V'(t) = C + \mu V(t)
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
5
Views
3K
Replies
3
Views
5K
Replies
4
Views
3K
Replies
5
Views
3K
Replies
1
Views
1K
Replies
3
Views
2K
Replies
6
Views
4K
Back
Top