Algorithm code
Solinit = bvpinit (linspace (, 5), [1 0]); % linspace (, 5) is the initial mesh, [] is the initial estimated value Sol = bvp4c (@ twoode, @ twobc, solinit); % twoode and twobc are the functions of the differential equation and the boundary condition, respectively, solinit is structured X = linspace (); % determines the X range y = Deval (sol, x); % determines the y range plot (X, Y (1 ,:)); % plot the graph % of Y-X to define the twoode function (the following code is saved as the twoode in the working directory. M file) function dydx = twoode (x, y) % differential equation Function Definition dydx = [Y (2)-ABS (Y (1)]; % defines the twobc function (the following code is saved as the twobc in the working directory. M file) function res = twobc (ya, Yb); % definition of the boundary condition function res = [ya (1); Yb (1) + 2];
Result
MATLAB basics ----------- methods for solving the edge Value Problem of ordinary differential equations using Matlab