WICHTIG: Der Betrieb von goMatlab.de wird privat finanziert fortgesetzt. - Mehr Infos...

Mein MATLAB Forum - goMatlab.de

Mein MATLAB Forum

 
Gast > Registrieren       Autologin?   

Partner:




Forum
      Option
[Erweitert]
  • Diese Seite per Mail weiterempfehlen
     


Gehe zu:  
Neues Thema eröffnen Neue Antwort erstellen

Guide funktioniert nach dem Neustart nicht mehr

 

Kupfera

Gast


Beiträge: ---
Anmeldedatum: ---
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 12.02.2016, 13:10     Titel: Guide funktioniert nach dem Neustart nicht mehr
  Antworten mit Zitat      
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.

Programm:
Code:
clc;
clear all;

function varargout = 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',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- 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;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes Lastganganalysetool1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = 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.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
 



Fehlercode:
Code:
>> Lastganganalysetool1
Error: File: Lastganganalysetool1.m Line: 4 Column: 1
Function definitions are not permitted in this context.


Ich hoffe jemand kann mir helfen, ich weiß nicht mehr weiter...


Harald
Forum-Meister

Forum-Meister


Beiträge: 24.501
Anmeldedatum: 26.03.09
Wohnort: Nähe München
Version: ab 2017b
     Beitrag Verfasst am: 12.02.2016, 14:04     Titel:
  Antworten mit Zitat      
Hallo,

das sollte nichts mit "nächstem Tag" oder so zu tun haben, sondern einfach nur mit diesem
Code:

das an dieser Stelle absolut sinnfrei ist.

Grüße,
Harald
Private Nachricht senden Benutzer-Profile anzeigen
 
Kupfera

Gast


Beiträge: ---
Anmeldedatum: ---
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 12.02.2016, 14:09     Titel:
  Antworten mit Zitat      
Ja, danke. Hat super funktioniert!

Jetzt weiß ich wo das Problem liegt. Danke Vielmals!!
 
Jan S
Moderator

Moderator


Beiträge: 11.057
Anmeldedatum: 08.07.10
Wohnort: Heidelberg
Version: 2009a, 2016b
     Beitrag Verfasst am: 13.02.2016, 00:17     Titel: Re: Guide funktioniert nach dem Neustart nicht mehr
  Antworten mit Zitat      
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
Private Nachricht senden Benutzer-Profile anzeigen
 
Neues Thema eröffnen Neue Antwort erstellen



Einstellungen und Berechtigungen
Beiträge der letzten Zeit anzeigen:

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
.





 Impressum  | Nutzungsbedingungen  | Datenschutz | FAQ | goMatlab RSS Button RSS

Hosted by:


Copyright © 2007 - 2025 goMatlab.de | Dies ist keine offizielle Website der Firma The Mathworks

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.