1
$\begingroup$

So I am currently taking a differential eq.s class, and am also learning how to use Matlab. I know Matlab is mostly used for numerical approximations, but I wanted to try to use the dsolve() command to symbolically solve some basic ODE's.

The equation in question is simply $$v^{'} = 9.8 - \frac{v}{5},$$ For which I know the solution is $$v = 49 + ce^{-t/5}.$$

In Matlab, I input this code, including the initial condition, and it keeps giving me the wrong answer for some reason. Matlab code

This is pretty much the simplest ODE that can be posed, and I am having problems getting Matlab to answer it; does anybody know what I'm doing wrong?

$\endgroup$
1
  • $\begingroup$ For symbolic calculations other softwares are likely more powerful. You can take a look at the matlab instruction ode45 while you are at it (which is very popular for numerical solving). $\endgroup$ Apr 5, 2017 at 21:29

2 Answers 2

1
$\begingroup$

Your code is too complicated. Here is the solution with only 3 lines of code:

>> syms v(t)
>> S=dsolve(diff(v)==9.8-v/5);
>> pretty(S)

        /   t \
  C2 exp| - - | + 49
        \   5 /
>> 
$\endgroup$
1
  • 1
    $\begingroup$ Ok, I realized now that I was making the oldest mistake in the books with my code, dividing my v by 2 instead of dividing it by 5. But your code is much simpler, thanks! $\endgroup$
    – Coolio2654
    Apr 5, 2017 at 21:32
1
$\begingroup$

Look again at what you wrote in your code,

y'(v) = 9.8-0.5*v

and compare with the ODE you wanted to solve

v'(t) = 9.5-v(t)/5
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .