Verfasst am: 06.12.2011, 16:17
Titel: Probleme bei der GUI
Hallo,
habe schon viel Hilfe hier bekommen...dafür bin ich echt dankbar!
Nun bin ich auch ein weiteres Problem gestoßen...trotz Tutorial und 2 Bücher.
Ich bekomme folgende Fehlermeldung:
Attempt to reference field of non-structure array.
Error in mlpa02_gui>pushbutton2_Callback (line 249)
l1num=str2double(get(handles.laenge1,'String'));
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in mlpa02_gui (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)mlpa02_gui('pushbutton2_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
Hier der m-Code der GUI:
Code:
functionvarargout = mlpa02_gui(varargin) % MLPA02_GUI MATLAB code for mlpa02_gui.fig % MLPA02_GUI, by itself, creates a new MLPA02_GUI or raises the existing % singleton*.
%
% H = MLPA02_GUI returns the handle to a new MLPA02_GUI or the handle to % the existing singleton*.
%
% MLPA02_GUI('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in MLPA02_GUI.M with the given input arguments.
%
% MLPA02_GUI('Property','Value',...) creates a new MLPA02_GUI or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before mlpa02_gui_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to mlpa02_gui_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help mlpa02_gui
% Last Modified by GUIDE v2.5 06-Dec-2011 13:38:27
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @mlpa02_gui_OpeningFcn, ...
'gui_OutputFcn', @mlpa02_gui_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
ifnargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
% --- Executes just before mlpa02_gui is made visible. function mlpa02_gui_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 mlpa02_gui (see VARARGIN)
% Choose default command line output for mlpa02_gui
handles.output = hObject;
% UIWAIT makes mlpa02_gui wait for user response (see UIRESUME) % uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line. functionvarargout = mlpa02_gui_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;
function laenge1_Callback(hObject, eventdata, handles) input=str2double(get(hObject,'String'));
if(isempty(input)) set(hObject,'String','1') end guidata(hObject, handles);
% hObject handle to laenge1 (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 laenge1 as text % str2double(get(hObject,'String')) returns contents of laenge1 as a double
% --- Executes during object creation, after setting all properties. function laenge1_CreateFcn(hObject, eventdata, handles) % hObject handle to laenge1 (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. ifispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');
end
function laenge2_Callback(hObject, eventdata, handles) input=str2double(get(hObject,'String'));
if(isempty(input)) set(hObject,'String','1') end guidata(hObject, handles);
% hObject handle to laenge2 (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 laenge2 as text % str2double(get(hObject,'String')) returns contents of laenge2 as a double
% --- Executes during object creation, after setting all properties. function laenge2_CreateFcn(hObject, eventdata, handles) % hObject handle to laenge2 (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. ifispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');
end
function laenge3_Callback(hObject, eventdata, handles) input=str2double(get(hObject,'String'));
if(isempty(input)) set(hObject,'String','1') end guidata(hObject, handles);
% hObject handle to laenge3 (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 laenge3 as text % str2double(get(hObject,'String')) returns contents of laenge3 as a double
% --- Executes during object creation, after setting all properties. function laenge3_CreateFcn(hObject, eventdata, handles) % hObject handle to laenge3 (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. ifispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');
end
function phi1_Callback(hObject, eventdata, handles) input=str2double(get(hObject,'String'));
if(isempty(input)) set(hObject,'String','0') end guidata(hObject, handles);
% hObject handle to phi1 (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 phi1 as text % str2double(get(hObject,'String')) returns contents of phi1 as a double
% --- Executes during object creation, after setting all properties. function phi1_CreateFcn(hObject, eventdata, handles) % hObject handle to phi1 (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. ifispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');
end
function phi2_Callback(hObject, eventdata, handles) input=str2double(get(hObject,'String'));
if(isempty(input)) set(hObject,'String','0') end guidata(hObject, handles);
% hObject handle to phi2 (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 phi2 as text % str2double(get(hObject,'String')) returns contents of phi2 as a double
% --- Executes during object creation, after setting all properties. function phi2_CreateFcn(hObject, eventdata, handles) % hObject handle to phi2 (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. ifispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');
end
function phi3_Callback(hObject, eventdata, handles) input=str2double(get(hObject,'String'));
if(isempty(input)) set(hObject,'String','0') end guidata(hObject, handles);
% hObject handle to phi3 (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 phi3 as text % str2double(get(hObject,'String')) returns contents of phi3 as a double
% --- Executes during object creation, after setting all properties. function phi3_CreateFcn(hObject, eventdata, handles) % hObject handle to phi3 (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. ifispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton2. function pushbutton2_Callback(hObject, eventdata, handles)
%Zuordnen der Eingabewerte-------------------------------------------------
%Umwandlung der Werte in double
%Funktionsaufruf um Punkte des Roboters zu erhalten------------------------
[A1,A2,A3,P]=mlpa02_math(phi1num,phi2num,phi3num,l1num,l2num,l3num);
%Umwandlung der Punkt Koordinaten in String--------------------------------
pxnum=num2str(P(1,1));
pynum=num2str(P(2,1));
pznum=num2str(P(3,1));
%Ausgabe in die Stringfelder-----------------------------------------------
set(handles.px,'String',pxnum);
set(handles.py,'String',pynum);
set(handles.pz,'String',pznum);
Setze doch ein Breakpoint, in die Zeile 249
Auf Button drücken, und Programm hält dann automatisch an der Stelle des Breakpoint an.
Du kannst dann im Command, deine Werte Aufrufen....
Verfasst am: 06.12.2011, 18:24
Titel: Re: Probleme bei der GUI
Hallo Chiefhood,
Du hast eine große Menge Code gepostet. Welches ist denn die Zeile 249, die die Fehlermeldung erzuegt?
Ich vermute, dass Du das Input-Argument "handles" noch nicht definiert hast, während die CreateFcn des Buttons läuft.
Hallo,
danke!!!
Jetzt funktionierst;)
habe lediglich das Problem wenn ich in ein Eingabefeld nichts eintrage...
wie kann ich das am besten machen?
Mit isempty?
also
Code:
ifisempty(l1num|l2num|l3num|phi1num|phi2num|phi3num) errordlg('Bitte ALLE Daten eingeben!!!') return end
Du kannst Beiträge in dieses Forum schreiben. Du kannst auf Beiträge in diesem Forum antworten. Du kannst deine Beiträge in diesem Forum nicht bearbeiten. Du kannst deine Beiträge in diesem Forum nicht löschen. Du kannst an Umfragen in diesem Forum nicht mitmachen. Du kannst Dateien in diesem Forum posten Du kannst Dateien in diesem Forum herunterladen
MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.