Matlab GUI set error

4 vues (au cours des 30 derniers jours)
Vineet Guru
Vineet Guru le 5 Juin 2013
Hi,
I keep getting this error and I don't know why. Or I know what is causing it but don't know how to resolve it. I need to load a .mat file which has a variable within called sMap. But if I load this file, the handles.box causes an error with the following remark.
Reference to non-existent field 'box'.
How can I load this mat file and still have access to the box.
= = =
The code is as follows:
% --- Executes just before UnsupervisedRecognitionEngine is made visible.
function UnsupervisedRecognitionEngine_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to UnsupervisedRecognitionEngine (see VARARGIN)
% Choose default command line output for UnsupervisedRecognitionEngine
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes UnsupervisedRecognitionEngine wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = UnsupervisedRecognitionEngine_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
B = xlsread('animals_data_newanimal.xlsx');
sDataStr_rec = som_data_struct(B);
sDataStr_rec=som_normalize_data(sDataStr_rec,'som_var_norm');
load('e:\matlab\ute01\animals.mat');
rec_bmu = som_bmus(sMap, sDataStr_rec);
n = strcat('The Best Matched Neuron is: ', num2str(rec_bmu));
set(handles.box,'string', n);
function box_Callback(hObject, eventdata, handles)
% hObject handle to box (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of box as text
% str2double(get(hObject,'String')) returns contents of box as a double
% --- Executes during object creation, after setting all properties.
function box_CreateFcn(hObject, eventdata, handles)
% hObject handle to box (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

Réponse acceptée

Image Analyst
Image Analyst le 5 Juin 2013
This link will help you solve this problem: http://blogs.mathworks.com/videos/2012/07/03/debugging-in-matlab/. Basically set a breakpoint at the line it gives you an error at, examine the handles structure, and see that box is not a member of handles. My guess are that the load() statement loads a handles that blows away your existing handles, or that you have a "clear" or something similar in there somewhere.
  1 commentaire
Vineet Guru
Vineet Guru le 6 Juin 2013
Hi Image Analyst,
Thanks for your answer. I actually found the answer on another blog query to which you responded suggesting how to pass variables between functions. This helped.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by