tmesh = linspace(0,pi/2,5);solinit = bvpinit(tmesh, @f);sol = bvp4c(@odefun, @bcfun, solinit); plot(sol.x, sol.y, '-o');
FUNCTION
function dzdt = odefun(t,z)dzdt = zeros(2,1); dzdt = [z(2)+z(1)]; end% boundary conditions
function res = bcfun(za, zb) res = [za(1) zb(pi/2)-2]end% Initial guess
function g = f(t) g = [sin(t) cos(t)];end
error unrecognized function or variable 'f'
Best Answer