function varargout = Lab31(varargin)
%---------------------------------------------------------------
%       USAGE: Lab31()
%
%      AUTHOR: Dr. Wayne Brown           DATE: 3 Nov 05
%
% DESCRIPTION: Plot a curve as two of its values are changed
%              by the user using slider bars.
%
%      INPUTS: None
%
%     OUTPUTS: None
%
%  REFERENCES: None
%---------------------------------------------------------------
% LAB31 M-file for Lab31.fig
%      LAB31, by itself, creates a new LAB31 or raises the existing
%      singleton*.
%
%      H = LAB31 returns the handle to a new LAB31 or the handle to
%      the existing singleton*.
%
%      LAB31('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in LAB31.M with the given input arguments.
%
%      LAB31('Property','Value',...) creates a new LAB31 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Lab31_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Lab31_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Copyright 2002-2003 The MathWorks, Inc.

% Edit the above text to modify the response to help Lab31

% Last Modified by GUIDE v2.5 10-Oct-2006 14:53:15

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Lab31_OpeningFcn, ...
                   'gui_OutputFcn',  @Lab31_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
   gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before Lab31_solution is made visible.
function Lab31_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to Lab31_solution (see VARARGIN)

% Choose default command line output for Lab31_solution
handles.output = hObject;

set(handles.Slider_a, 'Value', pi);
set(handles.Slider_a, 'Min',   0.0);
set(handles.Slider_a, 'Max',   2*pi);

set(handles.Slider_b, 'Value', 0.0);
set(handles.Slider_b, 'Min',   -10.0);
set(handles.Slider_b, 'Max',   +10.0);

Update_plot(handles);

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes Lab31 wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = Lab31_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;

% --- Executes on slider movement.
function Slider_a_Callback(hObject, eventdata, handles)
% hObject    handle to Slider_a (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

Update_plot(handles);

% --- Executes during object creation, after setting all properties.
function Slider_a_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Slider_a (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background, change
%       'usewhitebg' to 0 to use default.  See ISPC and COMPUTER.
usewhitebg = 1;
if usewhitebg
    set(hObject,'BackgroundColor',[.9 .9 .9]);
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on slider movement.
function Slider_b_Callback(hObject, eventdata, handles)
% hObject    handle to Slider_b (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

Update_plot(handles)

% --- Executes during object creation, after setting all properties.
function Slider_b_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Slider_b (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background, change
%       'usewhitebg' to 0 to use default.  See ISPC and COMPUTER.
usewhitebg = 1;
if usewhitebg
    set(hObject,'BackgroundColor',[.9 .9 .9]);
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

%----------------------------------------------------------------
function Update_plot(handles)

A = get(handles.Slider_a, 'Value');
B = get(handles.Slider_b, 'Value');
X = -10:0.1:10;
Line_handle = plot(handles.Plot_axes, X, cos(X+A) + sin(B*X) );
set(handles.Plot_axes, 'YLim', [-2 2]);

set(handles.Title_text, 'String', ...
    ['cos(x+' num2str(A) ') + sin(' num2str(B) 'x)'] );


% --------------------------------------------------------------------
function Untitled_1_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function Untitled_2_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes during object creation, after setting all properties.
function figure1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called


