Solution to Basic ODE using Matlab?

176 Views Asked by At

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?

2

There are 2 best solutions below

1
On BEST ANSWER

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 /
>> 
0
On

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