%
% File: bbeamc.m
% Controller for ball and beam simulation
% Created by Marc Bodson. Last revised: 05/25/25
%
% Control computations
%
% TO BE FILLED
%
% Store the results
%
if ip<=npoints 
   ts(ip)=t;xrefs(ip)=xref;xs(ip)=xball;vs(ip)=vball;
   if (theta>thmax);theta=thmax;end
   if (theta<-thmax);theta=-thmax;end
   ths(ip)=theta;
   ip=ip+1;
end
if ip>npoints;done=1;end   % Stop the simulation when done