Parameters Class

Parameters Class helps to add, set or remove parameters to the Project Class. The class has a constructor that gets initiated when Parameter class is called. This constructor sets important initial values to the class obj (object) like variable name, types. It also initiates a “table” that helps to store all the parameters. Table is a really useful data type provided by matlab. Check this link to know more about table.

The methods on the left call the methods on the right in the table.

Method in Project Class

Method in Parameters Class

projectClass.addParameterGroup()

parametersClass.addParameter()

projectClass.addParameter()

parametersClass.addParameter()

projectClass.removeParameter()

parametersClass.removeParameter()

projectClass.setParameter()

parametersClass.setParameter()

projectClass.setParameter()

parametersClass.setValue()

When adding parameters, they can be added individually or as a group (see below). When added as a group, addParameterGroup method in projectClass iterates over the list of parameters and adds them one by one using addParameter method which is used to add individual parameters.

Adding parameters as a group. Can set to a class using projectClass.addParameterGroup(Parameters)
    Parameters = {
    %   Name                min         val         max     fit?
    {'Oxide thick',         5,         20,         60,     true   };
    {'Oxide SLD',           3e-6,       3.41e-6,    4e-6,   false  };
    {'Oxide Hydration'      0,          20,         30,     true   }};
Adding parameters individually. Can set to a class using projectClass.addParameter(Parameter)
    Oxide =     {'Oxide Layer',...          % Name of the layer
                'Oxide thick',...           % Layer thickness
                'Oxide SLD',...             % Layer SLD
                'Substrate Roughness',...   % Layer roughness
                'Oxide Hydration',...       % Oxide hydration (percent)
                'bulk out' };               % Which bulk phase is hydrating the layer

% Add this to the projectClass...
projectClass.addLayer(Oxide);

When addParameter method is called, the method checks the input through a series of checks to find out if there are any unexpected values at unexpected places. For example, having logical value in place of a numerical value argument. With setParameter method, one can set the value of any parameter independently. However, there are other methods that helps setting individual parameters. For example, setName method helps to set the name of a parameter.

Note

  1. You can add Bulk in and Bulk out with this class

  2. You can add scale factor with this class

Reference

class API.projectClass.parametersClass(varargin)

This is the class definition for the parameters block.

addParameter(varargin)

Adds an new parameter to the parameters table. Default values are used when adding the parameter if no arguments are provided, otherwise a subset of the arguments can be provided. The following are assumed from number of arguments: for 1 input, the name only is provided for 2 inputs, the name and value are provided for 4 inputs, the name, min, value, and max are provided for 5 inputs, the name, min, value, max, and fit? are provided for 8 inputs, all parameter properties are provided

params.addParameter(‘Tails Roughness’);

displayTable()

Displays the parameter table

parametersClass(varargin)

Class constructor. Creates a Parameter object. The arguments should be the content of the first parameter. A parameter consists of a name (string), min (double), value (double), max (double), fit flag (logical), prior type (string), mu (double), and sigma (double) values in that order. Default values are used when adding the parameter if no arguments are provided, otherwise a subset of the arguments can be provided. The following are assumed from number of arguments: for 1 input, the name only is provided for 2 inputs, the name and value are provided for 4 inputs, the name, min, value, and max are provided for 5 inputs, the name, min, value, max, and fit? are provided for 8 inputs, all parameter properties are provided

params = parametersClass(‘Tails’, 10, 20, 30, true, priorTypes.Uniform.value, 0, Inf);

removeParameter(row)

Removes a parameter from the parameters table. Expects a single parameter name or index/array of parameter names or indices to remove

params.removeParameter(2);

setFit(row, fitFlag)

Sets the ‘fit’ to off or on for parameter. Expects index or name of parameter and new fit flag

params.setFit(2, true);

setLimits(row, min, max)

Sets the limits of an existing parameter. Expects index or name of parameter and new min and max of the parameter’s value

params.setLimits({2, 0, 100});

setName(row, name)

Sets the name of an existing parameter. Expects index or name of parameter and the new name

params.setName(2, ‘new name’);

setParameter(row, varargin)

General purpose set parameter method. Expects index or name of parameter and keyword/value pairs to set

params.setParameter(2, ‘value’, 50);

setPrior(row, varargin)

Sets the prior of an existing parameter. Expects index or name of parameter and the new prior type (‘uniform’, ‘gaussian’, ‘jeffreys’) with mu and sigma value if applicable

params.setPrior(2, priorTypes.Gaussian, 1, 2);

setValue(row, value)

Sets the value of an existing parameter. Expects index or name of parameter and the new value

params.setValue(2, 3.4);

toStruct()

Converts the class parameters into a structure array.