function varargout = lb(varargin)

% Last Modified by GUIDE v2.0 14-Aug-2000 11:52:46

if nargin == 0  % LAUNCH GUI

  fig = openfig(mfilename,'reuse');

  % Use system color scheme for figure:
  set(fig,'Color',get(0,'defaultUicontrolBackgroundColor'));

  % Generate a structure of handles to pass to callbacks, and store it. 
  handles = guihandles(fig);
  guidata(fig, handles);
  
  % Populate the listbox
  update_listbox(handles)
  set(handles.listbox1,'Value',[])
  
  if nargout > 0
    varargout{1} = fig;
  end

elseif ischar(varargin{1}) % INVOKE NAMED SUBFUNCTION OR CALLBACK

  try
    [varargout{1:nargout}] = feval(varargin{:}); % FEVAL switchyard
  catch
    disp(lasterr);
  end

end


function varargout = update_button_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles.pushbutton1.
update_listbox(handles)

function update_listbox(handles)
% Updates the listbox to match the current workspace
  vars = evalin('base','who');
  set(handles.listbox1,'String',vars)
  
function [var1,var2] = get_var_names(handles)
% Returns the names of the two variables to plot
list_entries = get(handles.listbox1,'String');
index_selected = get(handles.listbox1,'Value');
if length(index_selected) ~= 2
	errordlg('You must select two variables','Incorrect Selection','modal')
else
	var1 = list_entries{index_selected(1)};
	var2 = list_entries{index_selected(2)};
end 

function varargout = plot_button_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles.pushbutton2.
[x,y] = get_var_names(handles);
evalin('base',['plot(',x,',',y,')'])

function varargout = semilogx_button_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles.pushbutton3.
[x,y] = get_var_names(handles);
evalin('base',['semilogx(',x,',',y,')'])

function varargout = semilogy_button_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles.pushbutton4.
[x,y] = get_var_names(handles);
evalin('base',['semilogy(',x,',',y,')'])

