Solving Diff. Equation in MATLAB: Need Help

  • MATLAB
  • Thread starter MJCfromCT
  • Start date
  • Tags
    Matlab
In summary, the conversation discusses a differential equation problem in MATLAB and the different methods for solving it, including using DSolve in Mathematica or the ode45 function in MATLAB. The equation involves forces and constants, and the conversation provides some guidance on how to set it up and find the solution. The conversation also mentions potential future steps for exploring the problem further.
  • #1
MJCfromCT
20
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
  • #2
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?
 
  • #3
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.
 
  • #4
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)
 
  • #5
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!
 
  • #6
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.
 

FAQ: Solving Diff. Equation in MATLAB: Need Help

What are the steps for solving a differential equation in MATLAB?

The steps for solving a differential equation in MATLAB are as follows:

1. Define the differential equation using the symbolic variable 'syms'.

2. Use the 'dsolve' function to obtain the general solution.

3. Assign values to any constants in the general solution.

4. Use the 'subs' function to substitute the values into the general solution.

5. Plot the solution using the 'ezplot' or 'plot' function.

Can I solve any type of differential equation in MATLAB?

Yes, MATLAB has a built-in function 'dsolve' that can solve a wide range of differential equations, including first-order, second-order, and higher-order equations.

What is the difference between symbolic and numerical solutions in MATLAB?

A symbolic solution in MATLAB is a mathematical expression that represents the solution to a differential equation using symbolic variables. A numerical solution, on the other hand, is a set of numerical values that approximate the solution to the equation.

Can I use MATLAB to solve differential equations with initial conditions?

Yes, the 'dsolve' function in MATLAB allows you to specify initial conditions for your differential equation. This will give you a specific solution that satisfies the given initial conditions.

Are there any special functions or toolboxes required for solving differential equations in MATLAB?

No, the 'dsolve' function is built-in to MATLAB and does not require any additional toolboxes. However, if you want to visualize your solutions or perform more advanced analysis, you may need to use additional functions or toolboxes such as 'ezplot' or 'ode45'.

Similar threads

Replies
1
Views
1K
Replies
5
Views
2K
Replies
3
Views
4K
Replies
4
Views
3K
Replies
5
Views
2K
Replies
1
Views
1K
Replies
3
Views
2K
Replies
8
Views
2K
Back
Top