Report Generator | ![]() ![]() |
Creating a New Attribute
You can create a new attribute by editing getinfo.m
. This methods file contains information on component attributes and how they are displayed in the component attribute page (shown in the Options tab of the Setup File Editor).
All attribute information for a component is taken from out.att.XXX
and out.attx.XXX
lines in getinfo.m
. The out.att.XXX
lines are attributes and the out.attx.XXX
lines are UI options. The out.attx.XXX
lines are optional; they do not need to be included in getinfo.m
. If you do not include them, default UI controls are used for the attribute.
Finding Attributes and Their Default Values
Find the following section in getinfo.m
.
%---------------------- ATTRIBUTES --------------------
%The out.att.XXX section sets attribute defaults.
out.att.Plot_Title = 'My Random Plot';
out.att.NumLines = [3];
This section shows that there are two attributes.
Adding a New Attribute and Default Value
Create another attribute called isVisibleAxes
. This attribute determines whether the figure axes are visible. The attribute will have a default value of logical 1 (axes on).
To complete this task, add the following line to this section.
out.att.isVisibleAxes = logical(1);
Specifying Attribute Name, Data Type and UI Control
To specify attribute name, data type, and UI Control, (corresponds to Att. name, Data type, and Control type fields in the Component Attributes page), find the following section in getinfo.m
.
%------------------ ATTRIBUTE DISPLAY ----------------- %The out.attx.XXX section sets attribute GUI information. %Each .attx structure has the following fields: % .String - Appears as a text field next to the UIcontrol % .Type - data type of the corresponding attribute. % STRING - character string % NUMBER - scalar or vector number % LOGICAL - boolean logical(1)/logical(0) % ENUM - enumerated list of STRING, NUMBER, or LOGICAL % CELL - cell array % OTHER - structure or object % note: "OTHER" has no automated uicontrol updating % .enumValues - options for an enumerated list (.Type='ENUM') % .enumNames - display representation of .enumValues % note: must be same length as .enumValues % note: empty enumNames implies display from enumValues % .UIcontrol - type of control to use in GUI % .numberRange - min and max values (.Type-'NUMBER') out.attx.Plot_Title.String='Title of created plot'; out.attx.Plot_Title.Type='STRING'; out.attx.Plot_Title.UIcontrol='edit'; out.attx.NumLines.String='Number of lines to appear in plot'; out.attx.NumLines.Type='NUMBER'; out.attx.NumLines.UIcontrol='slider'; out.attx.NumLines.numberRange=[inf inf];
Attribute Name. out.attx.isVisibleAxes.String
is the name of the attribute as it appears in the Setup File Editor (corresponding to the Att. name field of the Component Attributes page in the Component Creation Wizard).
To create the attribute name for isVisibleAxes
called 'Make figure axes visible'
, add the following line to this section.
out.attx.isVisibleAxes.String='Make figure axes visible';
Attribute Data Type. out.attx.isVisibleAxes.Type
is the data type of the attribute (corresponds to the Data type field of the Component Attributes page in the Component Creation Wizard).
To specify the data type for isVisibleAxes
to be logical, add the following line to this section.
out.attx.isVisibleAxes.Type='LOGICAL';
LOGICAL
sets the data type to be a logical or Boolean number.
Note If you do not set the type, the Report Generator will infer the type from the default value you supplied earlier. |
Attribute UI Control. out.attx.isVisibleAxes.UIcontrol
is the type of UI control for the attribute (corresponding to the Control type option of the Component Attributes page in the Component Creation Wizard).
To specify the UI control for isVisibleAxes
to be a check box, add the following line to this section.
out.attx.isVisibleAxes.UIcontrol='checkbox';
Creating Another Attribute
Create another attribute called AxesColor
, which lets the user choose one of four colors for the axes: white, green, red and blue. The default color will be white. The name of the attribute, as is appears in the Setup File Editor, will be Color of Axes
.
To do this task, add the following lines of code to getinfo.m
(comments are preceded by `%'
and are optional).
% This creates an attribute called AxesColor, which has a default
% color of white (1 1 1).
out.att.AxesColor=[1 1 1]
; % This creates a name for the attribute, which appears in the % attribute page in the Options tab.out.attx.AxesColor.String='Color of axes';
% This creates an enumerated list with color choices of % white (1 1 1), green (0 1 0), red (1 0 0), and blue (0 0 1). out.attx.AxesColor.enumValues = {[1 1 1] [0 1 0] [1 0 0] [0 0 1]}; % This creates the names for the entries in the enumerated % list: white, green, red and blue.) out.attx.AxesColor.enumNames = {'white' 'green' 'red' 'blue'};
Note that out.attx.AxesColor.UIcontrol and out.attx.AxesColor.Type are not specified here. A default UI control and data type are used, according to the default value.
Changing a Previously Created Attribute
You can change a field for any attribute that you create by editing the getinfo.m
.
The slider created for NumLines
has a range of -inf
to inf
.
out.attx.NumLines.numberRange=[-inf inf];
A slider by default has a range of: [-inf +inf]
; it guesses about the range. Change the slider range to [1 10]
(minimum and maximum number of lines).
![]() | Using the New Component | Changing the Outline String | ![]() |