ich habe innerhalb eines Test-GUI's eine Funktion geschrieben inenrhalb welcher Variablen angelegt werden. Jedoch wird nach erfolgreichem Ausführen der Funktion der workspace gelöscht und die Variablen sind fort. Wie kann ich das unterdrücken?
Hier mein Code:
Code:
functionvarargout = Datenmanagement(varargin) % DATENMANAGEMENT M-file for Datenmanagement.fig % DATENMANAGEMENT, by itself, creates a new DATENMANAGEMENT or raises the existing % singleton*.
%
% H = DATENMANAGEMENT returns the handle to a new DATENMANAGEMENT or the handle to % the existing singleton*.
%
% DATENMANAGEMENT('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in DATENMANAGEMENT.M with the given input arguments.
%
% DATENMANAGEMENT('Property','Value',...) creates a new DATENMANAGEMENT or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before Datenmanagement_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to Datenmanagement_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 Datenmanagement
% Last Modified by GUIDE v2.5 15-Nov-2011 16:03:05 % Stop Debugger for Error Point dbstopiferror;
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Datenmanagement_OpeningFcn, ...
'gui_OutputFcn', @Datenmanagement_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
ifnargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
% --- Executes just before Datenmanagement is made visible. function Datenmanagement_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 Datenmanagement (see VARARGIN)
% Choose default command line output for Datenmanagement
handles.output = hObject;
% UIWAIT makes Datenmanagement wait for user response (see UIRESUME) % uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line. functionvarargout = Datenmanagement_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 edit1_Wert1_Callback(hObject, eventdata, handles) % hObject handle to edit1_Wert1 (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 edit1_Wert1 as text % str2double(get(hObject,'String')) returns contents of edit1_Wert1 as a double
% --- Executes during object creation, after setting all properties. function edit1_Wert1_CreateFcn(hObject, eventdata, handles) % hObject handle to edit1_Wert1 (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 edit2_Wert2_Callback(hObject, eventdata, handles) % hObject handle to edit2_Wert2 (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 edit2_Wert2 as text % str2double(get(hObject,'String')) returns contents of edit2_Wert2 as a double
% --- Executes during object creation, after setting all properties. function edit2_Wert2_CreateFcn(hObject, eventdata, handles) % hObject handle to edit2_Wert2 (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 edit3_Wert3_Callback(hObject, eventdata, handles) % hObject handle to edit3_Wert3 (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 edit3_Wert3 as text % str2double(get(hObject,'String')) returns contents of edit3_Wert3 as a double
% --- Executes during object creation, after setting all properties. function edit3_Wert3_CreateFcn(hObject, eventdata, handles) % hObject handle to edit3_Wert3 (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 pushbutton1_Daten_einlesen. function pushbutton1_Daten_einlesen_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1_Daten_einlesen (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton2_Datenaenderung_speichern. function pushbutton2_Datenaenderung_speichern_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2_Datenaenderung_speichern (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
Datenaenderung();
guidata(hObject, handles);
Zunächst einmal ist dies das gewollte Verhalten. Beim Verlassen einer funktion wird ihr Workspace gelöscht.
Wenn Du von einer anderen Stelle auf Variablen zugreifen möchtest, kannst Du sie als GLOBAL deklarieren. Deutlich sicherer wäre es allerdings, die Variablen per GUIDATA, SETAPPDATA oder SET(FigHandle, 'UserData') im GUI zu speichern und mit den dazugehörigen Methoden wieder auszulesen. Dies wurde hier im Forum mehrfach besprochen und die Suchfunktion sollte Dir weiterhelfen.
ich habe schon vor deinerAntwort dern Thread auf Status: beantwortet gesetzt, aber danke für den Hinweis. Ich habs so gelöst das ich die Variablen über handles gespeichert und über guidate(hObject, handles) gespeichert. so kann ich die innerhalb des guis verwenden
Einstellungen und Berechtigungen
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.