function [lambda,eigenvec]=slsolve(varargin) %This function solves the Sturm-Liouville eigenvalue problem given by: % % [p(x) y']' - q(x) y + lambda w(x) y = 0 % % subject to the boundary conditions: % % bc(1) y(0) + bc(2) y'(0) = 0 % % bc(3) y(1) + bc(4) y'(1) = 0 % % over the domain 0< x <1. % % The function is called by the command: % % [lambda,eigenvec]=slsolve('pfun','qfun','wfun',bc,n); % % The function call requires that you provide the function names (or % handles if you are using the anonymous function utility) for the % functions p, q, and w. These functions must be able to handle an array % of values. You also provide the boundary coefficients in the array bc. % In addition, you may specify the degree of discretization n. Its default % value is 50. The matrices which are generated are of size (n+1,n+1). % The function returns the eigenvalues in the array lambda (sorted by size % in ascending order) and the matrix eigenvec which contains the % corresponding eigenfunctions. The eigenfunctions are all normalized by % their maximum value over the domain 0