In: Advanced Math
what is the code to solve and graph the following function in matlab
dv/dt=80.5(1-e^(.4t))
>>syms v(t) %We just defined a symbolic function
>>ode = diff(v,t) == 80.5*(1-exp(4*t)) %we made the differential equation of v interms of t and
stored it in ode
>>vSol=dsolve(ode) %we used dsolve to solve the equation ode and stored the
function in vSol
Output
C1 + (161*t)/2 - (161*exp(4*t))/8
NOTE: we didnt give it any initial conditions so it put in a constant C1.
If you want to add an initial condition then add the following line before using dsolve
>>cond1 = v(0) == 'some number here' %cond1 is the name of the condition
then instead of last line use :
>>vSol = dsolve(ode,cond1)
Graphing
Here iam going to assume the constant C1 to be 0.
>> t=linspace(0,30,300); %this basically gives t values from 0-30 divided into 300 equal parts
>> v=(161*t)/2 - (161*exp(4*t))/8;
>>plot(t,v);