Q:

Initial Value Prob in Matlab

Suppose a symbolically defined f(t) satisfies the initial value problem f′(t) + 2 sin(t) = f(t) with f(pi) = 0. Use dsolve wrapped in subs to find f(0).
My answer is:
answer = subs( dsolve( diff(f,1)+2*sin(t) == f , f(pi) == 0), t, 0)

However, that gave me the wrong output, could anyone help explain?

A:

The issue ended up being defining issues. I had created 2 symbolic functions f(t) and f(x). Matlab had issues distinguishing between the 2.
A simple extra input argument was enough to tell Matlab which function I was referring too (the t variable one).
answer = subs( dsolve( diff(f,1)+2*sin(t) == f , f(pi) == 0, t), t, 0)

