function fsbvp echo off; clc; clear all; close all; % Example-4: Two second order odes - BVP % U.Akman 2004 % See help on BVP4C, BVPINIT, @. solinit = bvpinit(linspace(0,1,11),[0 0 1 1]) sol = bvp4c(@fsode,@fsbc,solinit) t = sol.x z = sol.y fprintf('\n'); fprintf('Value z_1 computed using infinity = %g is %7.5f.\n',1,z(1,end)) fprintf('Value z_3 computed using infinity = %g is %7.5f.\n',1,z(3,end)) figure plot(t,z(1,:),t(end),z(1,end),'o'); title('z_1 & z_3') xlabel('t') ylabel('z1 & z3') hold on plot(t,z(3,:),t(end),z(3,end),'o'); % -------------------------------------------------------------------------- function dfdeta = fsode(t,z) dfdeta = [ z(2) z(1)+2*z(3)+t z(4) 3*z(1)+2*z(3)+1 ]; % -------------------------------------------------------------------------- function res = fsbc(z0,zinf) res = [z0(1) z0(3) zinf(1) - 1 zinf(3) - 1];