function compdem(action)
% MATLAB Compiler information 

%   Yama Habibzai
%   Copyright (c) 1984-98 by The MathWorks, Inc. All Rights Reserved
%   $Revision: 1.8 $
%   5/15/96

if nargin<1,
  fig = findobj('Type', 'figure', 'Name', 'Compiler Info');
  
  if isempty(fig)
    figpos = getfgpos(560, 420);
    fig = figure('NumberTitle', 'off',...
        'Position', figpos, 'Name', 'Compiler Info',...
        'Resize', 'off',...
        'Color', [.8 .8 .8]);
    
  end
  %----------
  labelColor=[0.8 0.8 0.8];
  yInitPos=0.90;
  top=0.95;
  bottom=0.05;
  left=0.85;
  btnWid=0.10;
  btnHt=0.10;
  %    % Spacing between the button and the next command's label
  spacing=0.04;
  %%---------------
  str1 = ' ';
  str2 = '                The MATLAB Compiler';
  str4 = 'With the MATLAB Compiler, you can automatically';
  str6 = 'generate optimized code from M-file functions.';
  str7 = 'By translating MATLAB code to C, the Compiler';
  str8 = 'can significantly speed up MATLAB applications';
  str9 = 'and development.';
  myxp(str1, str2, str1, str4, str6, str7, str8, str9);
  
  button = findobj(gcf, 'type', 'uicontrol', 'Tag', 'contbutton');
  if exist('button')
    delete(button);
  end
  
  push_right = uicontrol('Style', 'Push',...
      'Units', 'Normalized',...
      'Position', [0.5339    0.0167    0.1250    0.0714],...
      'String', 'Next >>>',....
      'Tag', 'contbutton', 'callback', 'compdem func2');
  
  push_right = uicontrol('Style', 'Push',...
      'Units', 'Normalized',...
      'Position', [0.3018 0.0167 0.125 0.0714],...
       'String', '<<< Back',....
      'Tag', 'contbutton', 'Enable', 'off', 'callback', ' ');
  
  push_right2 = uicontrol('Style', 'Push',...
      'Units', 'Normalized',...
      'Position', [ 0.8196    0.0167    0.0804    0.0714],...
      'String', 'Exit', 'callback', 'close');
  
  
else,
  switch action
  case 'func2',func2;
  case 'func3', func3;
  case 'func4', func4;
  case 'func5', func5;
  case 'func6', func6;
  case 'func7', func7;
  case 'func8', func8;
  case 'open_eval', open_eval;
  end
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% Local Functions %%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function func2()
button = findobj(gcf, 'type', 'uicontrol', 'Tag', 'contbutton');
if exist('button')
  delete(button);
end

s1 = 'FEATURES:';
st = '          ';
s2 = '- Automatically converts M-file functions to'; 
s3=  '  high-performance C code';
s4 = '- Significantly increases execution speed'; 
s5 = '- Enables the incorporation of MATLAB code';
s6 = '  into other applications when used with the';
s7 = '  MATLAB C Math Library';
s8 = '- Generates well-commented and portable C code';
s9=  '  that is easy to maintain and update';
s10= '- Provides code hiding to protect proprietary';
s11= '  algorithms';

myxp(s1,st, s2, s3,st, s4,st, s5,s6, s7,st, s8, s9,st, s10, s11);

push_right2 = uicontrol('Style', 'Push',...
    'Position', [300 8 70 30], 'String', 'Next >>>',...
    'Tag', 'contbutton', 'callback', 'compdem func3');


push_right = uicontrol('Style', 'Push',...
    'Position', [170 8 70 30], 'String', '<<< Back',....
    'Tag', 'contbutton', 'Enable', 'on', 'callback', 'compdem');

function func3()
button = findobj(gcf, 'type', 'uicontrol', 'Tag', 'contbutton');
if exist('button')
  delete(button);
end

s1 = '             HIGHLIGHTS';
st = '          ';
sb = 'Faster Execution Speed:';
sc = '          ';
s2 = 'The matrix language and math functions in';
s3=  'MATLAB are already optimized for fast array';
s4=  'operations. But, other types of code, such as';
s5=  'scalar-based operations, may speed up';
s6=  'significantly when converted into C. The'; 
s7 = 'compiler makes this conversion fast and';
s8 = 'straightforward.';
myxp(s1,st, sb,sc, s2, s3, s4, s5, s6, s7, s8);

push_right2 = uicontrol('Style', 'Push',...
    'Position', [300 8 70 30], 'String', 'Next >>>',...
    'Tag', 'contbutton', 'callback', 'compdem func4');


push_right = uicontrol('Style', 'Push',...
    'Position', [170 8 70 30], 'String', '<<< Back',....
    'Tag', 'contbutton', 'Enable', 'on', 'callback', 'compdem func2');

function func4()
button = findobj(gcf, 'type', 'uicontrol', 'Tag', 'contbutton');
if exist('button')
  delete(button);
end

s1 = 'Shorter Development Time:';
s2 = '                 ';
s3 = 'The Compiler saves you valuable development';
s4 = 'time by providing an automated path from the';
s5=  'interactive prototyping environment of MATLAB';
s6 = 'to high-performance math-based applications.';

myxp(s1, s2,s2, s3,s2, s4,s2, s5,s2, s6);

push_right2 = uicontrol('Style', 'Push',...
    'Position', [300 8 70 30], 'String', 'Next >>>',...
    'Tag', 'contbutton', 'callback', 'compdem func5');

push_right = uicontrol('Style', 'Push',...
    'Position', [170 8 70 30], 'String', '<<< Back',....
    'Tag', 'contbutton', 'Enable', 'on', 'callback', 'compdem func3 ');

function func5()
button = findobj(gcf, 'type', 'uicontrol', 'Tag', 'contbutton');
if exist('button')
  delete(button);
end

s1 = 'MATLAB Code or Standalone Code:';
ss = '                   ';
s2 = 'The Compiler generates code for two types';
s3 = 'of executable programs: MEX-files and';
s4 = 'standalone executables. MEX-files are MATLAB';
s5 = 'executable functions that are called from';
s6 = 'MATLAB and dynamically linked at runtime.';
s7 = 'Standalone functions generated by the Compiler';
s8 = 'can be embedded into applications running';
s9 = 'outside the MATLAB environment. By linking';
s10 ='these standalone programs with the MATLAB';
s11 ='C Math Library, you can make the core math';
s12= 'capabilities of MATLAB the foundation for';
s13= 'numerically intensive external applications.';

myxp(s1,ss,s2,s3,s4,s5,s6,s7,s8, s9, s10,s11,s12,s13);

push_right2 = uicontrol('Style', 'Push',...
    'Position', [300 8 70 30], 'String', 'Next >>>',...
    'Tag', 'contbutton', 'callback', 'compdem func6');

push_right = uicontrol('Style', 'Push',...
    'Position', [170 8 70 30], 'String', '<<< Back',....
    'Tag', 'contbutton', 'Enable', 'on', 'callback', 'compdem func4');

function func6()
button = findobj(gcf, 'type', 'uicontrol', 'Tag', 'contbutton');
if exist('button')
  delete(button);
end

s1 = '    Compiler Execution Speed Comparison';
s2 = '            ';
s3 = 'The next two windows will display a sample,';
s4 = 'M-file code and a bar graph which compares the';
s5 = 'speed of the original M-file to a MEX-file';
s6 = 'generated by the MATLAB Compiler for the sqrtfib';
s7 = 'function with n = 5000. Compiling the M-file';
s8 = 'sqrtfib without options increases the executions';
s9 = 'speed by a factor of 5. Using the option -ri';
s10= '(real , array in-bounds) increases execution';
s11= 'speed by a factor of 15.';

myxp(s1,s2,s3,s4,s5,s6,s7,s8,s9,s10, s11);

push_right2 = uicontrol('Style', 'Push',...
    'Position', [300 8 70 30], 'String', 'Next >>>',...
    'Tag', 'contbutton', 'callback', 'compdem func7');

push_right = uicontrol('Style', 'Push',...
    'Position', [170 8 70 30], 'String', '<<< Back',....
    'Tag', 'contbutton', 'Enable', 'on', 'callback', 'compdem func5');


function func7()
button = findobj(gcf, 'type', 'uicontrol', 'Tag', 'contbutton');
if exist('button')
  delete(button);
end

s1 = '%%% sqrtfib M-file function %%%';
s2 = '          ';
s3 = 'function g = sqrtfib(n)';
s4 = '% Sqrt of fibonacci numbers';
s5 = 'f = zeros(1,n);';
s6 = 'f(1) = 1;';
s7 = 'if n <2, return, end';
s8 = 'f(2) = 1';
s9 = 'if n < 3, return, end';
s10 = 'for i = 3:n';
s11 = '   f(i) = f(i-1)+f(i-2);';
s12 = 'end';
s13 = 'g = sqrt(f);';

myxp(s3, s4, s2, s5, s6,s7,s8,s9, s10,s11,s12, s13);

push_right2 = uicontrol('Style', 'Push',...
    'Position', [300 8 70 30], 'String', 'Next >>>',...
    'Tag', 'contbutton', 'callback', 'compdem func8');

push_right = uicontrol('Style', 'Push',...
    'Position', [170 8 70 30], 'String', '<<< Back',....
    'Tag', 'contbutton', 'Enable', 'on', 'callback', 'compdem func6');

  push_right2 = uicontrol('Style', 'Push',...
      'Position', [460 8 45 30], 'String', 'Exit', 'callback', 'close');

function func8()
button = findobj(gcf, 'type', 'uicontrol', 'Tag', 'contbutton');
if exist('button')
  delete(button);
end

clf;
x = [1 2 3];
y = [377 66 25];
bar(x,y)
set(gca, 'xlim', [0 4])
set(gca, 'ylim', [0 500])
set(gca, 'xticklabel', [])
text(.88, 390, '377', 'fontName', '8x16');
text(1.9, 80, '66', 'fontName', '8x16');
text(2.9, 40, '25', 'fontName', '8x16');
text(.8, -20, 'M-file');
text(1.8, -20, 'Compiled');
text(2.8, -20, 'Compiled');
text(2.8, -40, '(reals)');
text(1.75, -40, '(no options)');
set(gca, 'ytick', [0 100 200 300 400 500]);
set(gca, 'xgrid', 'off');    
set(gca, 'ygrid', 'on');    
text(1.3, 460, 'Execution Time (msec)', 'fontName', '8x16');


push_right2 = uicontrol('Style', 'Push',...
    'Position', [460 8 55 28], 'String', 'Done',...
    'Tag', 'contbutton', 'callback', 'close');


push_right = uicontrol('Style', 'Pushbutton',...
    'Position', [72 8 55 28], 'String', '< Back',....
    'Tag', 'contbutton', 'Enable', 'on', 'callback', 'compdem func7');




