function perf3
% This example illustrates techniques for
% updating graphs efficiently

%  Copyright 2004 The MathWorks, Inc.

    % Generate inital data for this example
    alpha = .002;
    beta = -.7;
    x = 200;
    t = 0:.2:x;
    calc_ydata = @(alpha,beta) exp(-alpha*t).*cos(beta*t);
    y = calc_ydata(alpha,beta);

% Set up and display GUI

    % Setting Renderer prevents MATLAB from 
    % selecting renderer (sets RenderMode to manual)
    figure('Renderer','painters')
    % Set axis limits and use fast drawing mode
    h = axes('XLim',[0 200],'YLim',[-1 1],...  
        'Position',[.145 .25 .775 .675],...     
        'Drawmode','fast');
    title('y = e^{-\alphat}cos(\betat)','FontSize',14)
    ylabel('y','Rotation',0);xlabel('t')
    hline = line('XData',t,'YData',y,'Color','blue');
    ManAxMode(h)

% Layout Annotation Text Boxes
    % Set Interpeter property to none for faster rendering
    htextboxA = annotation('textbox',[.145 .08 .095 .1],...
        'Interpreter','none',... 
        'String',...
        ['Alpha = ',num2str(alpha)]);
    htextboxB = annotation('textbox',[.575 .08 .095 .1],...
        'Interpreter','none',... 
        'String',...
        ['Beta = ',num2str(beta)]);
    drawnow
    
% Layout sliders
    aslider = uicontrol('Style','slider',...
        'Max',.02,'Min',.002,...
        'Value',.002,...
        'Position',[80 20 200 20],...
        'Callback',@slider_callback);
    bslider = uicontrol('Style','slider',...
        'Max',.7,'Min',-.7,...
        'Value',-.7,...
        'Position',[320 20 200 20],...
        'Callback',@slider_callback);

% Callback function used by both sliders
    function slider_callback(src,evt)
        alpha = get(aslider,'Value');
        beta = get(bslider,'Value');
        y = calc_ydata(alpha,beta);
        % Set line object data
        set(hline,'YData',y) 
        % Set textbox string
        set(htextboxA,'String',{['Alpha = ',num2str(alpha)]})
        set(htextboxB,'String',{['Beta = ',num2str(beta)]})
        drawnow
    end

% This function sets most axes mode properties to manual
    function ManAxMode(h)
    % Do not set CameraViewAngleMode, DataAspectRatioMode,
    % and PlotBoxAspectRatioMode to aviod exposing a bug
    pn = {'ALimMode',...
        'CameraPositionMode','CameraTargetMode',...
        'CameraUpVectorMode','CLimMode',...
        'TickDirMode','XLimMode',...
        'YLimMode','ZLimMode',...
        'XTickMode','YTickMode',...
        'ZTickMode','XTickLabelMode',...
        'YTickLabelMode','ZTickLabelMode'};
    for k = 1:15
        pv(k) = {'manual'};
    end
    set(h,pn,pv)
    end

end