% Script/Function Filename:
%     plotCylinderGUI.m
% Purpose:
%     Enter the purpose of the function/file here
%     
% Record of modifications:
%     Programmer(s): {Your Name}
%     Date Due: YYYY-MM-DD
%     Date Submitted: YYYY-MM-DD
%     References: ????
%     Help Received: ????
%     
% Variables Used:
%     Enter the other variables that you use here}

height = rand() * 100;
radius = rand() * 100;

[ X , Y , Z ] = cylinder( 1 , 1000 );
X = X * radius;
Y = Y * radius;
Z = Z * height;
surf( X , Y , Z , 'EdgeColor' , [ 0 0 1 ] , 'FaceColor' , [ 0 0 1 ] );
t = linspace( 0 , 2 * pi , 999 );
t = [ t 0 ];
x = radius * cos( t );
y = radius * sin( t );
patch( x , y , zeros( size( x ) ) , 'b' );
patch( x , y , ones( size( x ) ) * height , 'b' );
ourAxes = gca;
set( ourAxes , 'XLim' , [ -100 100 ] );
set( ourAxes , 'ZLim' , [ 0 100 ] );
set( ourAxes , 'YLim' , [ -100 100 ] );
set( ourAxes , 'NextPlot' , 'ReplaceChildren' );
set( ourAxes , 'XLimMode' , 'Manual' );
set( ourAxes , 'YLimMode' , 'Manual' );
set( ourAxes , 'ZLimMode' , 'Manual' );
heightSlider = uicontrol( 'style' , 'slider' , 'units' , 'normalized' , ...
    'position' , [ 0 0.05 0.05 1 ] , 'min' , 0 , ...
    'max' , 100 , 'value' , height );
radiusSlider = uicontrol( 'style' , 'slider' , 'units' , 'normalized' , ...
    'position' , [ 0.05 0 1 0.05 ] , 'min' , 0 , ...
    'max' , 100 , 'value' , radius );
addlistener( heightSlider , 'ContinuousValueChange' , @updateHeight );
addlistener( radiusSlider , 'ContinuousValueChange' , @updateRadius );
set( 1 , 'UserData' , { height , radius , ourAxes } );

[ volume , surfaceArea ] = cylinderInfo( height , radius );

set( 1 , 'NumberTitle' , 'off' );
set( 1 , 'Name' , sprintf( ...
    'Height: %.2f Radius: %.2f Volume: %.2f Surface Area: %.2f' , ...
    height , radius , volume , surfaceArea ) );