No BSD License  

Highlights from
INCA Matlab Auto Calibration Wizard

image thumbnail

INCA Matlab Auto Calibration Wizard

by

 

27 Sep 2007 (Updated )

This is a Matlab application which accesses the INCA API and guides users through the process of aut

optimization(varargin)
function varargout = optimization(varargin)
% OPTIMIZATION M-file for optimization.fig
%      OPTIMIZATION, by itself, creates a new OPTIMIZATION or raises the existing
%      singleton*.
%
%      H = OPTIMIZATION returns the handle to a new OPTIMIZATION or the handle to
%      the existing singleton*.
%
%      OPTIMIZATION('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in OPTIMIZATION.M with the given input arguments.
%
%      OPTIMIZATION('Property','Value',...) creates a new OPTIMIZATION or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before optimization_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to optimization_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

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

% Last Modified by GUIDE v2.5 16-Feb-2006 12:08:18

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @optimization_OpeningFcn, ...
                   'gui_OutputFcn',  @optimization_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


function optimization_OpeningFcn(hObject, eventdata, handles, varargin)
%%***********************************************************************
%%	Method: optimization_OpeningFcn
%%	Purpose: Initializes variables to be used by optimization.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      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 optimization (see VARARGIN)
%%	Returns: none
%%***********************************************************************
    %Choose default command line output for optimization
    handles.output = hObject;
    
    %Initialize global variable.
    handles.optimization_vars = [];
    
    %Read in data from the autocal application.
    handles.desired_function=getappdata(0,'desired_func');
    handles.desired_action=getappdata(0,'desired_opt');
    set(handles.func,'String',handles.desired_function);
    set(handles.result,'Value',handles.desired_action);

    %Assign the passed data to the variables variable.
    variables = [varargin{:}];
    
    %Read in variables, and convert to a selection listing...
    for counter=1:length(variables)
        handles.optimization_vars=[handles.optimization_vars;{char(variables{counter})}];
    end
    
    %Update the GUI.
    set(handles.measvars,'String',handles.optimization_vars);

    %Save globals.
    guidata(hObject, handles);


function varargout = optimization_OutputFcn(hObject, eventdata, handles)
%%***********************************************************************
%%	Method: optimization_OutputFcn
%%	Purpose: Directs the output for the GUI.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      eventdata: reserved - to be defined in a future version of MATLAB
%%      handles: structure with handles and user data (see GUIDATA)
%%	Returns:
%%      varargout:  cell array for returning output args (see VARARGOUT)
%%***********************************************************************
    % Get default command line output from handles structure
    varargout{1} = handles.output;


function result_Callback(hObject, eventdata, handles)
%%***********************************************************************
%%	Method: result_Callback
%%	Purpose: Allows the user to change the optimization operation when
%%      result is changed.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      eventdata: reserved - to be defined in a future version of MATLAB
%%      handles: structure with handles and user data (see GUIDATA)
%%	Returns: none
%%***********************************************************************
    %Store which option has been selected.
    handles.desired_action=get(hObject,'Value');
    
    %Save globals.
    guidata(hObject, handles);


function result_CreateFcn(hObject, eventdata, handles)
%%***********************************************************************
%%	Method: result_CreateFcn
%%	Purpose: Executes during object creation, after setting all properties.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      eventdata: reserved - to be defined in a future version of MATLAB
%%      handles: structure with handles and user data (see GUIDATA)
%%	Returns: none
%%***********************************************************************
    if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
        set(hObject,'BackgroundColor','white');
    end


function measvars_Callback(hObject, eventdata, handles)
%%***********************************************************************
%%	Method: measvars_Callback
%%	Purpose: Executes on selection change in measvars.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      eventdata: reserved - to be defined in a future version of MATLAB
%%      handles: structure with handles and user data (see GUIDATA)
%%	Returns: none
%%***********************************************************************
    %This function does nothing.


function measvars_CreateFcn(hObject, eventdata, handles)
%%***********************************************************************
%%	Method: measvars_CreateFcn
%%	Purpose: Executes during object creation, after setting all properties.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      eventdata: reserved - to be defined in a future version of MATLAB
%%      handles: structure with handles and user data (see GUIDATA)
%%	Returns: none
%%***********************************************************************
    if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
        set(hObject,'BackgroundColor','white');
    end


function add_Callback(hObject, eventdata, handles)
%%***********************************************************************
%%	Method: add_Callback
%%	Purpose: Allows the user to add a variable to the end of the
%%      optimization function when the Add to End of Function button is
%%      pressed.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      eventdata: reserved - to be defined in a future version of MATLAB
%%      handles: structure with handles and user data (see GUIDATA)
%%	Returns: none
%%***********************************************************************
    %Retrieve the current listing of measurement variables from the GUI.
    available = get(handles.measvars,'String');
    
    %Determine which measurement variable is selected from the list, and
    %retrieve the name of this variable.
    position = get(handles.measvars,'Value');
    name = available{position};
    
    %Append the variable name on to the optimization function, and update
    %the function in the GUI, along with the global variable.
    current_function = get(handles.func,'String');
    new_function = strcat([current_function,name]);
    set(handles.func,'String',new_function);
    handles.desired_function = new_function;
    
    %Save globals.
    guidata(hObject, handles);

    
function func_Callback(hObject, eventdata, handles)
%%***********************************************************************
%%	Method: func_Callback
%%	Purpose: Allows the user to save the optimization function to a global
%%      variable when the function is changed.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      eventdata: reserved - to be defined in a future version of MATLAB
%%      handles: structure with handles and user data (see GUIDATA)
%%	Returns: none
%%***********************************************************************
    %Store the function contents to the global variable.
    handles.desired_function = get(handles.func,'String');
    
    %Save globals.
    guidata(hObject, handles);

    
function func_CreateFcn(hObject, eventdata, handles)
%%***********************************************************************
%%	Method: func_CreateFcn
%%	Purpose: Executes during object creation, after setting all properties.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      eventdata: reserved - to be defined in a future version of MATLAB
%%      handles: structure with handles and user data (see GUIDATA)
%%	Returns: none
%%***********************************************************************
    if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
        set(hObject,'BackgroundColor','white');
    end


function ok_button_Callback(hObject, eventdata, handles)
%%***********************************************************************
%%	Method: ok_button_Callback
%%	Purpose: Allows the user to close the application when the OK button is
%%      pressed, saving changes.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      eventdata: reserved - to be defined in a future version of MATLAB
%%      handles: structure with handles and user data (see GUIDATA)
%%	Returns: none
%%***********************************************************************
    %Send application data back to the autocal application.
    setappdata(0,'desired_opt',handles.desired_action);
    setappdata(0,'desired_func',handles.desired_function);
    setappdata(0,'action','ok');
    
    %Close the application.
    close;

 
function cancel_button_Callback(hObject, eventdata, handles)
%%***********************************************************************
%%	Method: cancel_button_Callback
%%	Purpose: Allows the user to close the application when the Cancel
%%      button is pressed, ignoring changes.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      eventdata: reserved - to be defined in a future version of MATLAB
%%      handles: structure with handles and user data (see GUIDATA)
%%	Returns: none
%%***********************************************************************
    %Send application data back to the autocal application.
    setappdata(0,'action','cancel');
    
    %Close the application.
    close;

Contact us