Verfasst am: 12.02.2016, 13:10
Titel: Guide funktioniert nach dem Neustart nicht mehr
Hallo, ich habe folgendes Problem: Wenn ich einen Button auf Guide programmiere funktioniert alles einwandfrei. Nun will ich am nächsten Tag weitermachen, öffne das Programm, aber der Programmcode hat auf einmal einen Fehler und geht nicht mehr.
functionvarargout = Lastganganalysetool1(varargin) % LASTGANGANALYSETOOL1 MATLAB code for Lastganganalysetool1.fig % LASTGANGANALYSETOOL1, by itself, creates a new LASTGANGANALYSETOOL1 or raises the existing % singleton*.
%
% H = LASTGANGANALYSETOOL1 returns the handle to a new LASTGANGANALYSETOOL1 or the handle to % the existing singleton*.
%
% LASTGANGANALYSETOOL1('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in LASTGANGANALYSETOOL1.M with the given input arguments.
%
% LASTGANGANALYSETOOL1('Property','Value',...) creates a new LASTGANGANALYSETOOL1 or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before Lastganganalysetool1_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to Lastganganalysetool1_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 Lastganganalysetool1
% Last Modified by GUIDE v2.5 12-Feb-2016 12:04:40
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Lastganganalysetool1_OpeningFcn, ...
'gui_OutputFcn', @Lastganganalysetool1_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
ifnargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
% --- Executes just before Lastganganalysetool1 is made visible. function Lastganganalysetool1_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 Lastganganalysetool1 (see VARARGIN)
% Choose default command line output for Lastganganalysetool1
handles.output = hObject;
% UIWAIT makes Lastganganalysetool1 wait for user response (see UIRESUME) % uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line. functionvarargout = Lastganganalysetool1_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 dateiauswahl. function dateiauswahl_Callback(hObject, eventdata, handles) % hObject handle to dateiauswahl (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) [xlsxfile,path2xlsx] = uigetfile('*.xlsx','Bitte Datei auswählen'); %Dateiauswahl
fid = fopen(fullfile(path2xlsx,xlsxfile),'r+'); % öffne Datei if fid == -1 %ueberprüfen ob Datei vorhanden
warning('Datei nicht gefunden')% wenn nicht wird eine Warnung ausgegeben end
% --- Executes on button press in pdifferenz. function pdifferenz_Callback(hObject, eventdata, handles) % hObject handle to pdifferenz (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
p=diff(leistung_Nov_15);
figure;
plot(datetime_Nov_15(1:2879),p,'-b','LineWidth',2);
title('Leistungsdifferenz vom 1.11 - 30.11');
legend('Leistungsdifferenz');
xlabel('Tage');
ylabel('Leistung');
grid;
[maxy, idx] = max(p);
maxx = datetime_Nov_15(idx);
hold on
plot(maxx, maxy, 'or','LineWidth',5)
maxi = max(p);
t = maxx;
TT=datestr(t);
fprintf('\n\nMaximale Leistungsverbrauch ist %dkW zu dem Datum %s.\n\n ',maxi,TT)
varlist = {'maxx','maxy','t','maxi','p','idx','TT','varlist'}; %damit werden die Variablen gelöscht und nicht im Workspace gespeichert
clear(varlist{:})
function edit1_Callback(hObject, eventdata, handles) % hObject handle to edit1 (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 as text % str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties. function edit1_CreateFcn(hObject, eventdata, handles) % hObject handle to edit1 (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
Verfasst am: 13.02.2016, 00:17
Titel: Re: Guide funktioniert nach dem Neustart nicht mehr
Hallo Kupfera,
Dieses CLEAR ist übrigens auch überflüssig:
Code:
varlist = {'maxx','maxy','t','maxi','p','idx','TT','varlist'}; %damit werden die Variablen gelöscht und nicht im Workspace gespeichert
clear(varlist{:})
Am Ende der Unterfunktion werden sowieso lle Variablen automatisch gelöscht, die nicht als Output übergeben werden.
Gruß, Jan
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.