No BSD License  

Highlights from
OCTool

from OCTool by Tim Farajian
This is a graphical interface for optimizing the time-delayed open/closed-loop control ...

octool(varargin)
function varargout = octool(varargin)
%OCTOOL M-file for OCTOOL.fig

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
    'gui_Singleton',  gui_Singleton, ...
    'gui_OpeningFcn', @octool_OpeningFcn, ...
    'gui_OutputFcn',  @octool_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 when user attempts to close the figure
function octool_CloseRequestFcn(hObject, eventdata, H)
% Now wish to delete the MAT-file used to save the historical data
if ~isempty(dir('tfGUI.mat'))
    delete('tfGUI.mat');
end
delete(hObject);


% --- Executes just before OCTOOL is made visible.
function octool_OpeningFcn(hObject, eventdata, H, varargin)
% This function sets up the default values for all editboxes.  Some are
% read directly from the current String property, others are determined
% based on those.

% Read in String properties
H.sys.cp = str2num(get(H.cpText,'String'));
H.sys.cd = str2num(get(H.cdText,'String'));
H.sys.a = str2num(get(H.aText,'String'));
H.sys.b = str2num(get(H.bText,'String'));
H.sys.uu = str2num(get(H.uuText,'String'));
H.sys.Gamma = str2num(get(H.yText,'String'));
H.sys.L = str2num(get(H.LText,'String'));
H.syst.B = str2num(get(H.BText,'String'));
H.syst.H = str2num(get(H.HText,'String'));
H.sys.xo = str2num(get(H.xoText,'String'));
H.sys.vo = str2num(get(H.voText,'String'));
H.syst.N = 1;
H.sys.To = str2num(get(H.tfText,'String'));
H.syst.T = H.sys.To/10;
H.sys.M = str2num(get(H.ndvText,'String'));
H.sys.IOL = get(H.IOL,'Value');
H.syst.Po = str2num(get(H.PoText,'String'));
H.syst.xf = str2num(get(H.xfText,'String'));

% Use callbacks to determine the rest of the values
nText_Callback(hObject, eventdata, H);
H = guidata(hObject);
delcheck_Callback(hObject, eventdata, H)
H = guidata(hObject);
mattypemenu_Callback(hObject, eventdata, H)
H = guidata(hObject);
shapetypemenu_Callback(hObject, eventdata, H);
H = guidata(hObject);
ictypemenu_Callback(hObject, eventdata, H)
H = guidata(hObject);
cstypemenu_Callback(hObject, eventdata, H)
H = guidata(hObject);
tftypemenu_Callback(hObject, eventdata, H)
H = guidata(hObject);

H.output = hObject; % For outputting the handle to the figure
guidata(hObject, H);


% --- Outputs from this function are returned to the command line.
function varargout = octool_OutputFcn(hObject, eventdata, H)
% Get default command line output from H structure
varargout{1} = H.output;






%%%
%%%  ALL EDITBOX CALLBACKS
%%%


function SText_Callback(hObject, eventdata, H)
% Callback from editing box
% CURRENTLY EDITBOX IS PERMANENTLY DISABLED %
H.sys.Alpha = str2num(get(hObject, 'String'));
guidata(H.octool, H);

function yText_Callback(hObject, eventdata, H)
% Callback from editing box
H.sys.Gamma = str2num(get(hObject, 'String'));
guidata(H.octool, H);

function EText_Callback(hObject, eventdata, H)
% Callback from editing box
H.syst.E = str2num(get(hObject, 'String'));
SetAlpha(H);

function RText_Callback(hObject, eventdata, H)
% Callback from editing box
H.syst.R = str2num(get(hObject, 'String'));
SetAlpha(H);

function IText_Callback(hObject, eventdata, H)
% Callback from editing box
H.syst.I = str2num(get(hObject, 'String'));
SetAlpha(H);

function AText_Callback(hObject, eventdata, H)
% Callback from editing box
H.syst.A = str2num(get(hObject, 'String'));
SetAlpha(H);

function LText_Callback(hObject, eventdata, H)
% Callback from editing box
H.sys.L = str2num(get(hObject, 'String'));
SetAlpha(H);

function HText_Callback(hObject, eventdata, H)
H.syst.H = str2num(get(H.HText, 'String'));
SetIA(H);

function BText_Callback(hObject, eventdata, H)
H.syst.B = str2num(get(H.BText, 'String'));
SetIA(H);


function xoText_Callback(hObject, eventdata, H)
H.sys.xo(get(H.xoslider, 'Value')) = str2num(get(hObject, 'String'));
guidata(H.octool, H);
SetICs(H);


function voText_Callback(hObject, eventdata, H)
H.sys.vo(get(H.voslider, 'Value')) = str2num(get(hObject, 'String'));
guidata(H.octool, H);
SetICs(H);

function uuText_Callback(hObject, eventdata, H)
% Callback from editing box
H.sys.uu = str2num(get(hObject, 'String'));
guidata(H.octool, H);

function cpText_Callback(hObject, eventdata, H)
% Callback from editing box
H.sys.cp = str2num(get(hObject, 'String'));
H.syst.cp = H.sys.cp; % Remember value
guidata(H.octool, H);

function cdText_Callback(hObject, eventdata, H)
% Callback from editing box
H.sys.cd = str2num(get(hObject, 'String'));
H.syst.cd = H.sys.cd; % Remember value
guidata(H.octool, H);

function aText_Callback(hObject, eventdata, H)
% Callback from editing box
aval = str2num(get(H.aMode, 'String'));
H.sys.a(aval) = str2num(get(hObject, 'String'));
guidata(H.octool, H);

function bText_Callback(hObject, eventdata, H)
% Callback from editing box
bval = str2num(get(H.bMode, 'String'));
H.sys.b(bval) = str2num(get(hObject, 'String'));
guidata(H.octool, H);

function tfText_Callback(hObject, eventdata, H)
% Callback from editing box
H.sys.To = str2num(get(hObject, 'String'));
guidata(H.octool, H);

function xfText_Callback(hObject, eventdata, H)
H.syst.xf = str2num(get(hObject, 'String'));
SetICs(H);

function PoText_Callback(hObject, eventdata, H)
H.syst.Po = str2num(get(hObject, 'String'));
SetICs(H);

function ndvText_Callback(hObject, eventdata, H)
H.sys.M = str2num(get(hObject, 'String'));
guidata(H.octool, H);

function delText_Callback(hObject, eventdata, H)
% Callback from editing box
H.sys.T = str2num(get(hObject, 'String'));
guidata(H.octool, H);

function nText_Callback(hObject, eventdata, H)
% When number of modes is changed, changes need to be made to the sliders
% and to the a, b, xo, and vo variables.
Nold = H.syst.N;
H.syst.N = str2num(get(H.nText, 'String'));
if Nold == H.syst.N
    return
end
if H.syst.N > 1
    % More than 1 mode
    if length(H.sys.a) < H.syst.N
        % Number has been increased
        H.sys.a(H.syst.N) = 0;
        H.sys.b(H.syst.N) = 0;
        H.sys.xo(H.syst.N) = 0;
        H.sys.vo(H.syst.N) = 0;
    else
        % Number has been decreased
        H.sys.a = H.sys.a(1:H.syst.N);
        H.sys.b = H.sys.b(1:H.syst.N);
        H.sys.xo = H.sys.xo(1:H.syst.N);
        H.sys.vo = H.sys.vo(1:H.syst.N);        
    end
    % Set the slider step ranges and values
    set([H.aslider H.bslider H.xoslider H.voslider], 'sliderstep',[0 0]+1/(H.syst.N-1));
    set([H.aslider H.bslider H.xoslider H.voslider], 'Value', 1, 'Max', H.syst.N);
    % Turn on sliders and mode text boxes
    set([H.aslider H.bslider  H.xoslider H.voslider H.aMode H.bMode H.xoMode H.voMode], 'Visible', 'on');
    % Use the slider callbacks to set the a, b, xo, and vo editboxes
    aslider_Callback(hObject, eventdata, H)
    bslider_Callback(hObject, eventdata, H)
    xoslider_Callback(hObject, eventdata, H)
    voslider_Callback(hObject, eventdata, H)    
else
    % Use only 1 mode
    H.sys.a(2:end) = [];
    H.sys.b(2:end) = [];
    H.sys.xo(2:end) = [];
    H.sys.vo(2:end) = [];    
    % Turn off the sliders and editboxes
    set([H.aslider H.bslider  H.xoslider H.voslider H.aMode H.bMode H.xoMode H.voMode], 'Visible', 'off');   
end
% Remember values in case they get turned off
H.syst.a = H.sys.a;
H.syst.b = H.sys.b;
H.syst.xo = H.sys.xo;
H.syst.vo = H.sys.vo;

guidata(H.octool, H);


%%%
%%%  DROP DOWN MENU CALLBACKS
%%%


function mattypemenu_Callback(hObject, eventdata, H)
% When set to <custom>, this enables the E and rho editboxes.  Otherwise,
% this disables the E and rho editboxes, and uses a default E and rho for
% the material specified.

Selection = get(H.mattypemenu, 'Value'); 
H.syst.mtm = Selection; % Remember menu setting

if Selection > 1 % Specified material
    % [steel, aluminum, castiron, wood, concrete]
    Eval = [200e9 73e9 90e9 12.1e9 35e9]; % Data for each material's E value
    Rval = [7830 2770 7640 500 2410]; % Data for each materials density
    H.syst.E = Eval(Selection-1); % Assign E for specified material
    H.syst.R = Rval(Selection-1); % Assign rho for specified material
    set([H.EText; H.RText], 'Enable', 'off'); % Disable editboxes
    WriteValue({'EText','RText'}, {H.syst.E, H.syst.R}, H);
else
    set([H.EText; H.RText], 'Enable', 'on'); % Enable editboxes
end
if isfield(H.syst,'I') % This can be false on startup
    SetAlpha(H);
else
    guidata(hObject,H);
end


% --- Executes on selection change in shapetypemenu.
function shapetypemenu_Callback(hObject, eventdata, H)
% This enables/disables the I, A, B, H, and Leditboxes based on the
% menu selection.
Selection = get(H.shapetypemenu, 'Value');
H.syst.stm = Selection; % Remember menu setting
if Selection==1 
    % Custom
    set([H.IText; H.AText],'Enable','on');
    set([H.HText;H.Hword;H.BText;H.Bword],'Visible','off');
elseif Selection==2,
    %Cylindrical
    set([H.IText;H.AText],'Enable','off');
    set([H.HText;H.Hword],'Visible','on');
    set([H.BText;H.Bword],'Visible','off');
    set(H.Hword, 'String', 'D');
    set([H.HText; H.Hword], 'Tooltip', 'Diameter (m)');
else
    %Rectangular or Triangular
    set([H.IText; H.AText], 'Enable', 'off');
    set([H.HText; H.Hword; H.BText; H.Bword], 'Visible', 'on');
    set(H.Hword, 'String', 'H');
    set([H.HText; H.Hword], 'Tooltip', 'Height (m)');
    
end
SetIA(H);


% --- Executes on selection change in ictypemenu.
function ictypemenu_Callback(hObject, eventdata, H)
% This controls the visibility the xo, vo, Po, and xf editboxes based on the
% menu selection.
Selection = get(H.ictypemenu, 'Value');
H.syst.itm = Selection;
if Selection==1,
    % Custom
    set([H.PoText;H.xfText],'Visible','off');
    set([H.xoText H.voText],'Enable','on'); 
elseif Selection==2,
    % Distributed load
    set(H.PoText,'Visible','on');
    set(H.xfText,'Visible','off');
    set([H.xoText H.voText],'Enable','off');
else
    % Concentrated load
    set([H.PoText;H.xfText],'Visible','on');
    set([H.xoText H.voText],'Enable','off');
end
SetICs(H);


% --- Executes on selection change in cstypemenu.
function cstypemenu_Callback(hObject, eventdata, H)
% This controls the visibility the cp, cd, a, and b editboxes based on the
% menu selection, and sets the appropriate values to zero.
Selection = get(H.cstypemenu, 'Value')-1;
H.sys.Type = Selection;
if any(Selection==[1 2 4 5])
    %Has closed P
    set(H.cpText,'Visible','on');
else
    set(H.cpText,'Visible','off');
    H.sys.cp = 0;
end
if sum(Selection==[3 2 6 5])>=1,
    %Has closed D
    set(H.cdText,'Visible','on');
else
    set(H.cdText,'Visible','off');
    H.sys.cd = 0;
end
h = [H.aslider H.bslider H.aMode H.bMode]; % Handles to sliders and editboxes
if any(Selection==[1 2 3 7])
    % Has open-loop control
    set([H.aText H.bText],'Visible','on');
    if H.syst.N > 1
        % More than one mode so sliders and editboxes are on
        set(h,'Visible','on');
    else        
        set(h,'Visible','off');
    end
else
    % No open-loop control
    set([H.aText H.bText],'Visible','off');
    set(h,'Visible','off');    
    H.sys.a = 0;
    H.sys.b = 0;
end
guidata(H.octool, H);


% --- Executes on selection change in tftypemenu.
function tftypemenu_Callback(hObject, eventdata, H)
% This is called when changing the optimization type menu setting.  No 
% other change necessary.  Just remember setting.
H.syst.ttm = get(H.tftypemenu, 'Value');
guidata(H.octool, H);


% --- Executes on button press in IOL.
function IOL_Callback(hObject, eventdata, H)
% No change necessary.  Just remember setting.
H.sys.IOL = get(hObject, 'Value');
guidata(H.octool, H);


% --- Executes on button press in delcheck.
function delcheck_Callback(hObject, eventdata, H)
% Turns on delayed editboxes
val = get(H.delcheck, 'Value');
if val
    % Button is checked
    set([H.delText H.ndvText],'Visible','on');
    H.sys.T = H.syst.T; % Reset to last value
else
    % Button is unchecked
    set([H.delText H.ndvText],'Visible','off');
    H.sys.T = 0; % Turn off delay
end
guidata(H.octool, H);


%%%
%%% BUTTON PRESS CALLBACKS
%%%


% --- Executes on button press in Pushbutton1.
function Pushbutton1_Callback(hObject, eventdata, H)
set(H.octool, 'Pointer', 'watch'); % Turn on watch shaped cursor
if get(H.dispcheck,'Value')
    % Determine if iterative display box is checked
    v={false,'disp','iter'}; % Set display parameter
else
    v={false,'disp','none'}; % No display parameter
end
tic
switch get(H.tftypemenu,'Value')
    case 1
        H.syst.P = performance(H.sys);
    case 2
        [H.sys H.syst.P] = oolp(H.sys);
    case 3
        [H.sys H.syst.P] = oclp(H.sys,v{:});
    case 4
        [H.sys H.syst.P] = opttime(H.sys,v{:});
    case 5
        [H.sys H.syst.P] = immediate(H.sys,v{:});
end
t = toc; % Remember run time
% Display Performance
set(H.pText,'String',sprintf('%0.4g',H.syst.P));
% Display run time
set(H.tmText,'String',sprintf('%0.4g',t));
guidata(H.octool, H);
sys2gui(H); % Set GUI to match the newly optimized system
set(H.octool, 'Pointer', 'arrow');

if ~isempty(dir('tfGUI.mat'))
    % Savefile already exists
    load tfGUI.mat Ht % Load past data
    Ht(end+1) = H; % Append current data
else
    Ht = H; % Initialize past data matrix
end
save tfGUI.mat Ht % Save past data
n = length(Ht);
% Save slider is only on after 2 optimizations have been run
if n==1
    set(H.SaveSlider, 'Value', n)
else
    set(H.SaveSlider, 'Vis', 'on', 'Max', n, 'Value', n, 'sliderstep',[0 0]+1/(n-1))
end
set(H.clrBut, 'Vis', 'on') % Turn the clear button on


% --- Executes on button press in clrBut
function clrBut_Callback(hObject, eventdata, H)
% Deletes the historical data MAT-file
if ~isempty(dir('tfGUI.mat'))
    delete('tfGUI.mat');
end
set(H.clrBut, 'Vis','off')
set(H.SaveSlider, 'Vis','off')


%%%
%%% SLIDER CALLBACKS
%%%

% --- Executes on save slider movement.
function SaveSlider_Callback(hObject, eventdata, H)
load tfGUI.mat Ht
v = get(H.SaveSlider, 'Value'); % Determine slider value
H = Ht(v); % Set current system to specified past system
guidata(H.octool, H);
sys2gui(H) % Set current system to GUI

% --- Executes on a slider movement.
function aslider_Callback(hObject, eventdata, H)
v = get(H.aslider, 'Value');
get(H.aslider, 'Max');
set(H.aMode, 'String', num2str(v));
set(H.aText,'String',sprintf('%0.4g',H.sys.a(v)));


% --- Executes on b slider movement.
function bslider_Callback(hObject, eventdata, H)
v = get(H.bslider, 'Value');
set(H.bMode, 'String', num2str(v));
set(H.bText,'String',sprintf('%0.4g',H.sys.b(v)));

% --- Executes on xo slider movement.
function xoslider_Callback(hObject, eventdata, H)
n = get(H.xoslider, 'Value');
get(H.xoslider, 'Max');
set(H.xoMode, 'String', num2str(n));
set(H.xoText,'String',sprintf('%0.4g',H.sys.xo(n)));

% --- Executes on vo slider movement.
function voslider_Callback(hObject, eventdata, H)
n = get(H.voslider, 'Value');
get(H.voslider, 'Max');
set(H.voMode, 'String', num2str(n));
set(H.voText,'String',sprintf('%0.4g',H.sys.vo(n)));


%%%
%%% THESE ARE THE MENU ITEM CALLBACKS
%%%


function modalresponsemenu_Callback(hObject, eventdata, H)
% Plot the response of the current system
if hObject==H.modalresponsemenu
    % Plot modal responses
    plotresponse(H.sys,true);
else
    % Plot total response
    plotresponse(H.sys,false);
end



function PhaseMenu_Callback(hObject, eventdata, H)
% Plot the response of the current system
H.sys.To = linspace(0,H.sys.To,100); % 100 discrete values over time
[t W dW Z dZ] = response(H.sys); % Calculate response
figure
plot(W,dW) % Plot phase


function AnimateMenu_Callback(hObject, eventdata, H)
% Animate the beam
animation(H.sys)



function Exportmenu_Callback(hObject, eventdata, H)
% This opens at dialog for the user to name the variable, then assigns it to
% the base workspace.
answer = inputdlg('Export to variable name:','Export',1,{'sys'});
if ~isempty(answer)
    H = guidata(H.octool);
    sprintf('The variable ''%s'' has been created in the current workspace.',answer{1});
    assignin('base',answer{1},H.sys);
end


function Generatemenu_Callback(hObject, eventdata, H)
% Generate Code callback
% Creates an M-file containing the code that performs the optimization that
% the settings currently represent.

% Determine name and directory for M-file
[FileName,PathName,FilterIndex] = uiputfile('*.m');
% Open file
fid = fopen(fullfile(PathName,FileName),'w');
% Beginning of M-file
fprintf(fid,'%% Create structure\nsys=ocset;\n');
% Read fields and values from current system
flds = fieldnames(H.sys);
vals = struct2cell(H.sys);
% Get default system
defsys = ocset;
% Starting string for each field assingment line
istr = 'sys = ocset(sys, '''; 
for n = 1:length(flds)
    valdef = [];
    if isfield(defsys,flds{n})
        valdef = getfield(defsys,flds{n});
    end
    if length(vals{n})~=length(valdef) || any(vals{n}~=valdef)
        if length(vals{n})==1
            fprintf(fid,[istr flds{n}, ''', ' num2str(vals{n},16) ');\n']);
        else
            fprintf(fid,[istr, flds{n}, ''', ', '[']);
            for m = 1:length(vals{n})
                fprintf(fid,num2str(vals{n}(m),16));
                if m<length(vals{n})
                    fprintf(fid,', ');
                end
            end
            fprintf(fid,']);\n');
        end
    end
end

fprintf(fid,'%% Perform optimization\n');
fprintf(fid,'tic\n');
fcnname = {'performance', 'oolp', 'oclp', 'opttime', 'immediate'};
I = get(H.tftypemenu,'value');
if I == 1
    fprintf(fid,'P = performance(sys);\n');
else
    fprintf(fid,['[osys P] = ' fcnname{I} '(sys);\n']);
end
fprintf(fid,'toc\n');

fclose(fid);
edit(FileName);


function HelpFileMenu_Callback(hObject, eventdata, handles)
% Opens the help information in notepad.
!notepad octoolhelp.txt


%%% 
%%% This Section contains helper functions (not callbacks)
%%%


function SetIA(H)
% For setting I and A after B H or L have changed
switch get(H.shapetypemenu, 'Value')
    case 2
        %Cylindrical
        H.syst.A = pi/4*H.syst.H^2;
        H.syst.I = pi/64*H.syst.H^4;
    case 3
        %Rectangular
        H.syst.A = H.syst.B*H.syst.H;
        H.syst.I = H.syst.B*H.syst.H^3/12;
    case 4
        %Rectangular
        H.syst.A = H.syst.B*H.syst.H/2;
        H.syst.I = H.syst.B*H.syst.H^3/36;
end
WriteValue({'AText','IText'}, {H.syst.A, H.syst.I}, H);
SetAlpha(H);


function SetAlpha(H)
% Computes and writes Alpha after E, I, R, A, or L have changed
H.sys.Alpha = (H.syst.E*H.syst.I/H.syst.R/H.syst.A/H.sys.L^4); % Compute Alpha
WriteValue('SText', H.sys.Alpha, H); % Write Alpha to editbox
guidata(H.octool, H);


function SetICs(H)
% Determines xo and vo based on the specified load and number of modes.
set(H.octool, 'Pointer','watch');
switch get(H.ictypemenu, 'Value');
    case 2
        % Distributed load 
        H.sys.xo = 4*H.syst.Po/H.syst.E/H.syst.I/H.sys.L^4./((1:H.syst.N)*pi).^5;
        H.sys.xo(2:2:end) = 0; % Even modes 0 due to symmetry
        H.sys.vo = zeros(size(H.sys.xo)); % Zero initial velocity        
    case 3
        % Concentrated load
        if H.syst.xf <= 0 | H.syst.xf >= H.sys.L
            % If for some reason xf is out of range, set it to midpoint
            H.syst.xf = H.sys.L/2;
        end
        npi = (1:H.syst.N)*pi; 
        PoEI = H.syst.Po/H.syst.E/H.syst.I; % Constant
        % Calculate initial displacement based on given concentrated load
        H.sys.xo = 1./3.*PoEI.*((H.syst.xf.^2.*npi.^2-(6+npi.^2).*H.sys.L.^2).*...
            H.syst.xf.*sin(npi)+6.*H.sys.L.^3.*sin(H.syst.xf.*npi./H.sys.L))./npi.^4;
        H.sys.vo=0*H.sys.xo;% Zero initial velocity
        H.sys.xo(abs(H.sys.xo)<eps(abs(H.sys.xo(1)))) = 0; % Ensure "near" zero is zero        
end
WriteValue({'xoText','voText'},{H.sys.xo(get(H.xoslider,'Value')),H.sys.vo(get(H.voslider,'Value'))},H);
guidata(H.octool, H);
set(H.octool, 'Pointer','arrow');



function sys2gui(H)
% Sets the GUI based on the current system
WriteValue({'yText','cpText','cdText','tfText','nText'},{H.sys.Gamma,H.sys.cp,H.sys.cd,H.sys.To,H.syst.N},H);
set([H.aslider H.bslider],'Value',1,'Max',H.syst.N);
if H.syst.N > 1
    set([H.aslider H.bslider], 'sliderstep',[0 0]+1/(H.syst.N-1));
else
    set([H.aslider H.bslider], 'sliderstep',[1 1]);
end
set(H.aMode,'String','1');
set(H.bMode,'String','1');
set(H.xoMode,'String','1');
set(H.voMode,'String','1');
set(H.aText,'String',sprintf('%0.4g',H.sys.a(1)));
set(H.bText,'String',sprintf('%0.4g',H.sys.b(1)));
set(H.xoText,'String',sprintf('%0.4g',H.sys.xo(1)));
set(H.voText,'String',sprintf('%0.4g',H.sys.vo(1)));
set(H.uuText,'String',['[' sprintf('%0.4g, ',H.sys.uu) ']']);
if isfield(H.syst, 'P')
    WriteValue({'pText'},{H.syst.P},H);
else
    WriteValue({'pText'},{[]},H);
end
set(H.mattypemenu,'Value',H.syst.mtm);
mattypemenu_Callback([], [], H)
set(H.shapetypemenu,'Value',H.syst.stm);
shapetypemenu_Callback([], [], H)
set(H.ictypemenu,'Value',H.syst.itm);
ictypemenu_Callback([], [], H)
set(H.cstypemenu,'Value',H.sys.Type+1);
cstypemenu_Callback([], [], H)
set(H.tftypemenu,'Value',H.syst.ttm);

if H.sys.T > 0
    set(H.delcheck,'Value',true);
else
    set(H.delcheck,'Value',false);
end

delcheck_Callback([], [], H)
if H.sys.IOL
    set(H.IOL,'Value',true);
else
    set(H.IOL,'Value',false);
end
delcheck_Callback([], [], H)


function WriteValue(Field, Val,H)
% Sets the String property of text boxes to specified values
if ~iscell(Field),
    Field = {Field};
end
if ~iscell(Val),
    Val = {Val};
end
for n = 1:length(Field)
    str = sprintf('%0.4g', Val{n});
    set(getfield(H,Field{n}), 'String',str);
end







Contact us at files@mathworks.com