I am currently trying to write a MATLAB code for solving The Sturm-Liouville system $$y''+ y=f(x) \quad \to (1)\\y(a)=\alpha\quad \to (2)\\y(b)=\beta\quad \to (3)$$ using Green's Function Method. We know by variation of parameters rule that the Green's Function is defined as $$G(x,\xi)=\dfrac{1}{W[\phi_1,\phi_2]}\begin{cases} \phi_1(x)\phi_2(\xi) , \quad a \le x \le \xi\\\phi_1(\xi)\phi_2(x) , \quad \xi \le x \le b\end{cases}$$
where $\phi_1$ is the soln of $(1),(2)$ and [$(3)$ homogeneous] and $\phi_2$ is the soln of $(1),(3)$ and [$(2)$ homogeneous].
I have computed $\phi_1$ and $\phi_2$ by
v=dsolve('D2y+y=0',in1,in4,x)
w=dsolve('D2y+y=0',in2,in3,x)
Please note that in$1$ and in$2$ are $(2)$ and $(3)$ while in$3$ and in$4$ are homogeneous $(2)$ and $(3)$ resp.
Now for computing Green's Function I have written the following code which does not work.
G =piecewise([a<=x and x<=s,v*subs(w,x,s)],[s<=x and x<=b,w*subs(v,x,s)]);
Can somebody rectify my Green's Function code so that it works. Thanks.