function [out1,out2,out3] = pend_options(t,y,flag,w)

if nargin < 3 | isempty(flag),
   out1= [y(2); -w^2*sin(y(1)) ];

else
   switch flag
      case 'init'                     % Return [tspan,y0,options].
         out1=linspace(0,6*pi,200);   % tspan
         out2=[0;1];                  % y0=col of initial coditions
         out3=odeset('outputsel',1);  % Plot only y(1) options.	  
	otherwise
         error(['Unknown flag ''' flag '''.']);
   end
end
