1
f(t,y)=3y

Intial Condition y(t)=0 when t=0 What is the solution when t=1

I dont want to solve it numercially, rather somthing like symbolic function. I am not able to include a way to find y(t) when t=1

syms y(t);
ode= diff(y,t) == 3*y;
    cond= y(0) == 0;
    ySol(t) = dsolve(ode,cond);
    fplot(ySol)

I have solved this function numerically and need to compare it with the real solution this I am trying to find a method of doing this on Matlab

  • @NickyMattsson How embarrassing. You're absolutely right. I blame it on the early morning... :) – joni Oct 12 '18 at 14:41

1 Answers1

0

doing this

syms y(t);
ode= diff(y,t) == 3*y;
cond= y(0) == 0;
ySol = dsolve(ode,cond)

you should get something like: ySol=0

to evaluate your symbolic expression use subs

subs(ySol, t, 1)

should return 0

and double(subs(ySol, t, 1))

should return 0.0

PilouPili
  • 2,601
  • 2
  • 17
  • 31
  • and use `double()` to make it a number if needed. – Ander Biguri Oct 12 '18 at 08:58
  • Eeh, no? the solution to y' = 3y is not exp(3t)-1, y'=3*exp(3t), whereas 3*y = 3exp(3t) - 3. The general solution is Cexp(3t) which for y(0)=0 gives y(t)=0. Which is also what `dsolve` returns – Nicky Mattsson Oct 12 '18 at 12:35
  • You are absolutely right @NickyMattsson. I did not test with matlab prior posting. OP misguided me saying a needed the eval of the solution at t=1 I wanted the solution to be a bit more complex than 0.... – PilouPili Oct 12 '18 at 12:47
  • @NPE understandable, I was also confused. – Nicky Mattsson Oct 12 '18 at 13:06