MATLAB弹出选择示例的遗留在那里

时间:2013-06-19 20:58:40

标签: matlab matlab-guide

我还在学习MATLAB的gui。我使用了GUIDE的模板之一,恰好是GUI with Axes and Menu

这将生成两个文件:GUIFigure.m和GUIFigure.fig

首先,我删除了为弹出菜单提供标签的行,其中包含以下行:

function popupmenu1_CreateFcn(hObject, eventdata, handles)
set(hObject, 'String', {'old text 1', 'old text 2');

当我用自己的文本替换大括号内的文本时,它工作正常。当我用一个单元格变量替换它并使用不正确的语法时,它会给我一个错误,这是可以理解的,但这个数字仍会弹出旧文本。

另一个类似的问题是该示例已经有一个带有轴的图。现在我从.fig文件中删除了轴,并且还删除了.m文件中的代码。但是当我运行gui函数时,轴仍然会显示图,尽管我甚至删除了为图生成数据的代码!

任何有关正在发生的事情的解释/提示都将受到赞赏。

function varargout = FIAFigure(varargin)
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @FIAFigure_OpeningFcn, ...
                   'gui_OutputFcn',  @FIAFigure_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 just before FIAFigure is made visible.
function FIAFigure_OpeningFcn(hObject, eventdata, handles, varargin)


% Choose default command line output for FIAFigure
handles.output = hObject;

handles.dataSetsCell = varargin{1};
handles.categoryNames = varargin{2};

% Update handles structure
guidata(hObject, handles);

if strcmp(get(hObject,'Visible'),'off')
    plot(rand(5));
end



% --- Outputs from this function are returned to the command line.
function varargout = FIAFigure_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;

% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
t = uitable(handles.uitable1);

cla;

popup_sel_index = get(handles.popupmenu1, 'Value');
set(t,'Data',magic(popup_sel_index))



% --------------------------------------------------------------------
function FileMenu_Callback(hObject, eventdata, handles)

% --------------------------------------------------------------------
function OpenMenuItem_Callback(hObject, eventdata, handles)
file = uigetfile('*.fig');
if ~isequal(file, 0)
    open(file);
end

% --------------------------------------------------------------------
function PrintMenuItem_Callback(hObject, eventdata, handles)
printdlg(handles.figure1)

% --------------------------------------------------------------------
function CloseMenuItem_Callback(hObject, eventdata, handles)
selection = questdlg(['Close ' get(handles.figure1,'Name') '?'],...
                     ['Close ' get(handles.figure1,'Name') '...'],...
                     'Yes','No','Yes');
if strcmp(selection,'No')
    return;
end

delete(handles.figure1)


% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
set(hObject, 'String', {handles.categoryNames{1:end}});


% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)

    if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
     set(hObject,'BackgroundColor','white');
    end


% --- Executes during object creation, after setting all properties.
function uitable1_CreateFcn(hObject, eventdata, handles)

0 个答案:

没有答案
相关问题