function [x w] = lfd(a,b,alpha,beta,N) h=(b-a)/(N+1); % Create the interior samples i=1,2,...N-1 x=(a+h:h:b-h)'; % Create the main diagonal md = 0; % Create the subdiagonal subd = 0; % Adjust the subdiagonal so that it will work with spdiags. Use the % vertcat command. subd = subd +0; % Create the superdiagonal supd = 0; % Adjust the superdiagonal so that it will work with spdiags. Use the % vertcat command. supd = supd +0; % Create the tridiagonal matrix A A=spdiags([subd md supd],-1:1,N,N); % Create the right hand side vector rhs=0; % Adjust the first and last values of rhs rhs(1)=rhs(1)+0; rhs(N)=rhs(N)+0; % Add the first and last values to the vector x x=vertcat(a,x,b); % Solve the system for w and then use vertcat to add the first and last % initial conditions w=vertcat(alpha,A\rhs,beta); function y = p(x) y=ones(numel(x),1); function y = q(x) y=2*ones(numel(x),1); function y = r(x) y = cos(x);