GUI + Reference to non-existent field

Dear All,
I'm new to Matlab GUI. I'm getting following error when I use GUIDE. "Reference to non-existent field 'axes5'.
Error in Filname>Filname_OpeningFcn(line84)
axes(handles.axes5);
Error in mainfcn(line221)
feval(gui_State.gui_OpeningFcn,gui_hFigure,[],guidata(gui_hFigure),varagin{:});
Error in Filname(line42)
gui_mainfun(gui_State,varagin{:});
Error in guidefunc>layoutActivate(line 1158)
feval(fcn);
Eror in guidefunc(line 13)
varagout=layoutActivate(varagin{:});"
Can anyone suggest

4 个评论

Post the line code causing the error
Here is the code for Main opening function. There are several push-buttons etc., but the problem error is pointing to this part of code.
CODE:
function varargout = GUI_FILENAME(varargin)
% Last Modified by GUIDE v2.5 08-Mar-2013 08:22:00
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @GUI_FILENAME_OpeningFcn, ...
'gui_OutputFcn', @GUI_FILENAME_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 GUI_FILENAME is made visible.
function GUI_FILENAME_OpeningFcn(hObject, eventdata, handles, varargin)
PH_nr = 0;
handles.PHnr = PH_nr;
Glob_limit = load(['Global_Limit_PH',num2str(PH_nr),'_Jan13.txt']);
Ref_Kentaal = load(['RefKEY_fine_PH_',num2str(PH_nr),'_Jan13.txt']);
folderpath = ['C:\Jan14-13\20130109'];
handles.folderpath = folderpath;
handles.Date = '20130109';
handles.pID = '43';
handles.Time = '1622';
handles.def_fold_0n = 0;
temp_str = ['Measurement',handles.Date,'_p',handles.printID];
jj = 1;
Nsrt = 0;
handles.sw_strt = Nsrt;
Nstp = 3;
handles.sw_end = Nstp;
Meas_no = Nsrt:Nstp;
handles.Nozz_logg = 0;
%-----------------------------------
axes(handles.axes5);
imshow('Company-logo.jpg');
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% --- Outputs from this function are returned to the command line.
function varargout = GUI_FILENAME_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
Wouldn't it be better to postpone the imshow('oce-logo.jpg'); until the open function for axes5 ?
Dear Azzi and Walter,
Thanks a lot for taking time to look at my problem. I just realized that I've used the first command 'clear all' to remove other data once I open the GUI. This was clearing the reference to hObject of the main function.
Now, my question to you is this:
If there are some variables with same name in workspace prior to opening the GUI, they are interfering with variables in GUI. This is the reason I thought lets clear the workspace once GUI is open.
How to ensure that the workspace is empty once you open the GUI?

请先登录,再进行评论。

回答(1 个)

Image Analyst
Image Analyst 2013-3-8
You don't need to worry about if there are some variables with the same name in a workspace prior to opening the GUI. They are in a different workspace and will not interfere. Each function has its own local, completely separate set of variables. When you did clear all you blew away your handles structure. Don't do that - if there are variables hanging around in the "base" workspace, it will not affect variables in your functions.

类别

帮助中心File Exchange 中查找有关 Graphics Objects 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by