Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
37
Добавлен:
24.02.2016
Размер:
56.83 Кб
Скачать

GUIDE Design GUI.

GUIDE initiates the GUI Design Environment tools that allow

FIG-files to be edited interactively. Calling GUIDE by itself will open a new untitled FIG-file. GUIDE(filename) opens the FIG-file named 'filename' if it is on the MATLAB path. GUIDE(fullpath) opens the FIG-file at 'fullpath' even if it is not on the MATLAB path.

GUIDE(HandleList) creates new FIG-files for each figure(s) containing handles in the HandleList and copies the contents of the figure(s)into the FIG-files.

See also INSPECT.

Inspect Open the inspector and inspect object properties

%| ABOUT CALLBACKS:

%| GUIDE automatically appends subfunction prototypes to this file, and sets objects' callback properties to call them through the FEVAL switchyard above. This comment describes that mechanism.

%|

%| Each callback subfunction declaration has the following form:

%| <SUBFUNCTION_NAME>(H, EVENTDATA, HANDLES, VARARGIN)

%|

%| The subfunction name is composed using the object's Tag and the

%| callback type separated by '_', e.g. 'slider2_Callback',

%| 'figure1_CloseRequestFcn', 'axis1_ButtondownFcn'.

%| H is the callback object's handle (obtained using GCBO).

%| EVENTDATA is empty, but reserved for future use.

%| HANDLES is a structure containing handles of components in GUI using tags as fieldnames, e.g. handles.figure1, handles.slider2. This structure is created at GUI startup using GUIHANDLES and stored in the figure's application data using GUIDATA. A copy of the structure is passed to each callback. You can store additional information in this structure at GUI startup, and you can change the structure during callbacks. Call guidata(h, handles) after changing your copy to replace the stored original so that subsequent callbacks see the updates. Type "help guihandles" and "help guidata" for more information.

%|

%| VARARGIN contains any extra arguments you have passed to the

%| callback. Specify the extra arguments by editing the callback

%| property in the inspector. By default, GUIDE sets the property to:

%| <MFILENAME>('<SUBFUNCTION_NAME>', gcbo, [], guidata(gcbo))

%| Add any extra arguments after the last argument, before the final closing parenthesis.

GUIHANDLES Return a structure of handles.

HANDLES = GUIHANDLES(H) returns a structure containing handles of objects in a figure, using their tags as fieldnames. Objects are excluded if their tags are empty, or are not legal variable names. If several objects have the same tag, that field in the structure contains a vector of handles. Objects with hidden handles are included in the structure.

H is a handle that identifies the figure - it can be the figure itself, or any object contained in the figure.

HANDLES = GUIHANDLES returns a structure of handles for the current figure.

Example:

Suppose an application creates a figure with handle F, containing a slider and an editable text uicontrol whose tags are 'valueSlider' and 'valueEdit' respectively. The following excerpts from the application's M-file illustrate the use of GUIHANDLES in callbacks:

... excerpt from the GUI setup code ...

f = figure;

uicontrol('Style','slider','Tag','valueSlider', ...);

uicontrol('Style','edit','Tag','valueEdit',...);

... excerpt from the slider's callback ...

handles = guihandles(gcbo); % generate handles struct

set(handles.valueEdit, 'string',...

num2str(get(handles.valueSlider, 'value')));

... excerpt from the edit's callback ...

handles = guihandles(gcbo);

val = str2double(get(handles.valueEdit,'String'));

if isnumeric(val) & length(val)==1 & ...

val >= get(handles.valueSlider, 'Min') & ...

val <= get(handles.valueSlider, 'Max')

% update the slider's value if the edit's value is OK:

set(handles.valueSlider, 'Value', val);

else

% flush the bad string out of the edit; replace with slider's

% current value:

set(handles.valueEdit, 'String',...

num2str(get(handles.valueSlider, 'Value')));

end

Note that in this example, the structure of handles is created each time a callback executes. See the GUIDATA help for an example in which the structure is created only once, and cached for subsequent use.

See also GUIDATA, GUIDE, OPENFIG.

OPENFIG Open new copy or raise existing copy of saved figure.

OPENFIG('NAME.FIG', 'new') opens figure contained in .fig file, NAME.FIG, and ensures it is completely on screen. Specifying the .fig extension is optional. Specifying the full path is optional as long as the .fig file is on the MATLAB path.

Соседние файлы в папке METOD