Verfasst am: 10.02.2014, 22:19
Titel: Problem mit Callback von popupmenu
Hallo,
ich versuche gerade über Popup-Menüs ein Geburtsdatum zu erfassen und die drei Komponenten (Tag, Monat, Jahr) in Variablen zuspeichern und im Workspace zuveröffentlichen.
Der Inhalt der Popup-Menüs ist auch richtig und beim Programmstart kann ich auch einfach Tag, Monat, Jahr auswählen. Aber mir werden die Werte nicht in den Variablen gespeichert. Also muss ja ein Problem im Callback vorliegen. Da ich absoluter Anfänger bin habe ich leider keine Ahnung, wie ich das hinbekomme.
Kopiere hier mal den Code rein, so wie er jetzt grade ist.
Code:
functionvarargout = AlterTest2(varargin) % ALTERTEST2 MATLAB code for AlterTest2.fig % ALTERTEST2, by itself, creates a new ALTERTEST2 or raises the existing % singleton*.
%
% H = ALTERTEST2 returns the handle to a new ALTERTEST2 or the handle to % the existing singleton*.
%
% ALTERTEST2('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in ALTERTEST2.M with the given input arguments.
%
% ALTERTEST2('Property','Value',...) creates a new ALTERTEST2 or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before AlterTest2_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to AlterTest2_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 AlterTest2
% Last Modified by GUIDE v2.5 10-Feb-2014 21:42:16
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @AlterTest2_OpeningFcn, ...
'gui_OutputFcn', @AlterTest2_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
ifnargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
% --- Executes just before AlterTest2 is made visible. function AlterTest2_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 AlterTest2 (see VARARGIN)
% Choose default command line output for AlterTest2
handles.output = hObject;
% UIWAIT makes AlterTest2 wait for user response (see UIRESUME) % uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line. functionvarargout = AlterTest2_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 selection change in GebTag. function GebTag_Callback(hObject, eventdata, GebTag) % hObject handle to GebTag (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns GebTag contents as cell array % contents{get(hObject,'Value')} returns selected item from GebTag
% --- Executes during object creation, after setting all properties. function GebTag_CreateFcn(hObject, eventdata, handles) % hObject handle to GebTag (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 selection change in GebMonat. function GebMonat_Callback(hObject, eventdata, handles) % hObject handle to GebMonat (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns GebMonat contents as cell array % contents{get(hObject,'Value')} returns selected item from GebMonat
% --- Executes during object creation, after setting all properties. function GebMonat_CreateFcn(hObject, eventdata, handles) % hObject handle to GebMonat (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 selection change in GebJahr. function GebJahr_Callback(hObject, eventdata, handles) % hObject handle to GebJahr (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns GebJahr contents as cell array % contents{get(hObject,'Value')} returns selected item from GebJahr
% --- Executes during object creation, after setting all properties. function GebJahr_CreateFcn(hObject, eventdata, handles) % hObject handle to GebJahr (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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
So.... Hab den ziemlich dummen Fehler schon gefunden... Hab mich einfach vertippt bei assignin und dann den Fehler überall anders ausgesucht. Jetzt funktioniert es jedenfalls.
Für alle anderen hier nochmal als Auszug:
Code:
function GebTag_Callback(hObject, eventdata, handles) % hObject handle to GebTag (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns GebTag contents as cell array % contents{get(hObject,'Value')} returns selected item from GebTag
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.