Verfasst am: 03.02.2010, 08:43
Titel: Erstellung eines Gui für Optimierungsaufgabe?
Hallo,
ich bin gerade an einer Optimierungsaufgabe und möchte dafür eine optisch schönere und angenehmer zu bedienende Benutzeroberfläche als die des Programmierfensters.
Nun habe ich mir das Tutorial zum Erstellen von Guis angeschaut und mir andere Hilfen durchgelesen.
Die sind auch alles eindeutig und verständlich, allerdings gelingt es mir nicht, es auf meine Aufgabe zu übertragen.
Stelle mich da möglicherweise ein wenig ungeschickt an.
Denke, das sollte für einen Geübten ein Kinderspiel darstellen.
Also, was soll mein Gui können:
- Es soll nacheinander die Eingabe verschiedener Werte abfragen, die
dann vom Benutzer eingegeben werden müssen
Also,
- Wie groß ist der Durchmesser? Eingabe des Durchmessers
- Wie groß ist die Schnitttiefe? Eingabe der Schnitttiefe
...
- Anhand dieser Werte soll nun mein Matlab-Algorithmus mit Hilfe seiner
Formeln Ergebnisse berechnen, die mir dann ausgegeben werden sollen.
Zum Verständnis, hier mein Algorithmus mit den Eingabeaufforderungen:
global fixed_cost C2 C3 X1 C5 C6 C4 X2 X3 C Cp C7 Pm;
d=input('Diameter of cutter: ');
arad=input('Radial Depth of Cut: '); % arad=4;
a=input('Axial Depth of Cut: '); % a=4;
K=input('Length to be travelled: ');
z=4; % z=input('Teeth of cutter: ');
ct=49.5; % ct=input('Tooling cost for selected tool: ');
Pm=10; % Pm=input('Motor power: ');
cut_mat=2; % cut_mat=input('1 for Carbide/2 for HSS/3 for Ceramics: ');
op_typ=1; % op_typ=input('1 for Face milling/2 for Plain and end milling: ');
Zusätzlich hat mein Algorithmus noch zwei Fenster für die Nebenbedingungen und eins für die Hauptfunktion. Sollten diese für die Erstellung des Gui wichtig sein, füge ich sie in einem weiteren Post gerne hinzu.
Kann mir jemand weiterhelfen? Komme da alleine nicht mit klar
also eine GUI beginnt ja mit function vargout = ...
also kannst du dein GUI am Anfang deinest Haupt-m-files mit
var=Name_deines_Gui;
aufrufen.
In deinem GUI setzt du mit dem Guide so viele Edit-Felder wie du brauchst.
In der OpeningFcn setzt du das auskommentierte
uiwait(handles.figure1);
aktiv.
Mit einem Button kannst du dann nach den Eingabe der Daten in der Funktion des Button die Edit-Felder auslesen. z.B. mit:
Code:
function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) uiresume;
Wie du nun die ausgelesenen Werte an deine OutputFcn übergeben kannst ist mir ein Rätsel und bisher habe ich auch keine Antwort auf meine Frage bekommen. Irgendwie schaffe ich es nicht über die hanldles-Struktur und über globale variablen geht es nicht.
Ich habe die Ergebnisse dann in eine .mat gespeichert und mit der OutputFcn wieder laden lassen. Ganz am Ende das Löschen nicht vergessen.
Also, ich habe nun die Optik des GUI erstellt und als .m file gespeichert.
Dann bekomme ich ein zusätzliches Fenster im Editor in das ich wohl nun das Auskommentierte eingebe.
Ist das richtig?
Meinst du mit dem "Auskommentierten" die anderen Fenster, die ich im Editor zur Verfügung habe?
Was meinst du denn mit "uiwait(handles.figure1); ?
Ich verstehe nicht so ganz, was ich mit dem neuen Fenster im Editor genau zu machen habe und wie dieses Fenster funktioniert.
Das GUI besteht ja aus einer .fig und einer .m. In der .fig sind nur die optische Anordnung und das, was du mit dem Property Inspector als Werte für deine Objekte eingestellt hast, gespeichert.
In der .m ist dein Quellcode gespeichert, also das, was passieren soll wenn die Objekte "aktiviert" werden. Am einfachsten siehst du was passiert wenn du ein neues, leeres GUI erstellst und dann sofort speicherst. Dann sind in der .m nämlich nur die notwendigen Grundfunktionen:
% --- Executes just before test is made visible. function test_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 test (see VARARGIN)
% Choose default command line output for test
handles.output = hObject;
% UIWAIT makes test wait for user response (see UIRESUME) % uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line. functionvarargout = test_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;
Also die OpeningFcn (die Dinge erledigt die gemacht werden sollen, bevor die .fig sichtbar gemacht wird. Da kannst du z.B. reinschreiben was die Startwerte in deinen Edit-Feldern sein sollen. Du findest dort auch die Kommentarzeile
Das ist es was ich mit auskommentiert meinte. Da machst du das % weg. Somit wartet dein GUI mit der OutputFcn (also dem zurückgeben des Rückgabewertes) so lange, bis du deine Eingaben in die Edit-Felder gemacht hast. Genauer gesagt, bis du in einer Funktion die Zeile
% --- Executes just before test is made visible. function test_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 test (see VARARGIN)
set(handles.edit1, 'String', 42); %Startwert für Edit-Feld
set(handles.pushbutton1, 'String', 'Ok'); %Schrift auf Button "Ok"
% Choose default command line output for test
handles.output = hObject;
% UIWAIT makes test wait for user response (see UIRESUME)
uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line. functionvarargout = test_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 pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) uiresume(handles.figure1);
close;
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
Wie du siehst, habe ich in der OpeningFcn dem Edit-Feld und dem Button schon mal einen Eintrag verpasst. AUf dem Button soll "Ok" stehen und im Edit-Feld soll der Startwert 42 stehen. Außerdem ist das % vor dem uiwait entfernt worden.
Der Button hat das uiresume bekommen und den Befehl close. Damit wird die .fig geschlossen.
Nun möchtest du wahrscheinlich nur Zahlen im Edit-Feld zulassen.
Da kannst du dann in die Funktion des Edit-Feldes folgendes reinschreiben:
Code:
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)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit1 as text % str2double(get(hObject,'String')) returns contents of edit1 as a double
Das schreibst du in die Callback-Funktion von Edit1. Die CreateFcn hab ich noch nie verändert.
So, nun musst du noch die eingegebenen Werte irgenwie auslesen.
Das würde ich vom Button erledigen lassen.
Code:
function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) uiresume(handles.figure1);
x=str2double(get(handles.edit1, 'String'));
save tmp.mat x;
close;
Da ich nun leider nicht weiß wie man die ausgelesenen Werte der OutputFcn übergibt, würde ich quick and dirty die Werte in eine Datei schreiben und dann entwerder von der OutputFcn oder in deinem eigentlichen Programm einlesen lassen.
In deinem eigentlichen Programm kannst du dann dein GUI einfach aufrufen, indem du Name_deines_Gui als Zeile einfügst.
danke für die Tipps.
Glaube das Meiste davon dürfte ich verstanden und auch umgesetzt haben.
Ein paar Fragen habe ich allerdings trotzdem noch:
1) Kann man die Eingaben, die in der Openingfct stehen nicht auch schon beim optischen Entwerfen des GUI diesem zuordnen?
Z.B. macht es doch keinen Unterschied, ob ich beim Entwerfen in die Editbox 8 reinschreibe oder erst in der Openingfct, oder?
2) Sollte es doch einen Unterschied machen: ich will dieses Edit-Feld eigentlich leer stehen haben. Durch nebenstehende Static Boxen soll dem Benutzer gesagt werden, welche Zahlenwerte er einzugeben hat, bzw. was von ihm gefordert ist.
Geht doch, oder?
3) Wie und wo schreibe ich denn in dieses komplette Fenster, bzw. diese Datei, mein Programm? Bis jetzt weiss doch das Programm bei Ausführung des GUI noch gar nicht, was es machen soll, oder? Es stellt doch zum jetzigen Zeitpunkt einzig und alleine eine optische Benutzeroberfläche bereit, oder? So wie ich das verstehe, ist die Berechnung meines Algorithmus für Matlab zu diesem Zeitpunkt noch nicht möglich.
1.) Die Eingaben kannst du auch schon im Property Inspector machen ja. Ob es da einen Unterschied gibt weiß ich nicht. Es funktioniert aber beides.
2.)Du kannst auch das Feld leer lassen, das geht.
3.)Nein dein GUI ist bisher nur ein GUI das Werte sammelt und in eine .mat schreibt.
Ich sehe da mehrere Möglichkeiten. Du kannst deine ganze Berechnung z.B. in der Funktion von dem Button durchführen. Einfach vor dem close; einfügen. Ob es auch nach dem close-Befehl geht weiss ich nicht, glaube aber nicht.
Oder was ich machen würde: Ich würde das GUI als eigenständiges Progrämmchen stehen lassen und in deiner Berechnung aufrufen.
Das sähe dann (analog zu meiner Antwort oben) z.B. so aus:
Habe nun versucht deine Anmerkungen umzusetzen. Dadurch, dass ich dieses ganze Zusammenspiel von Matlabs editor Dateien jedoch nicht wirklich durchschaue, stieß ich mal wieder an meine Grenzen und das Ganze läuft nicht.
Hänge hier einfach mal meine Fenster an. Da kannst du vielleicht schneller sehen, wo Befehle nicht so aufgenommen wurden, wie es eigentlich hätte sein sollen.
functionvarargout = GUI_1_voll(varargin) % GUI_1_VOLL M-file for GUI_1_voll.fig % GUI_1_VOLL, by itself, creates a new GUI_1_VOLL or raises the existing % singleton*.
%
% H = GUI_1_VOLL returns the handle to a new GUI_1_VOLL or the handle to % the existing singleton*.
%
% GUI_1_VOLL('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in GUI_1_VOLL.M with the given input arguments.
%
% GUI_1_VOLL('Property','Value',...) creates a new GUI_1_VOLL or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before GUI_1_voll_OpeningFunction gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to GUI_1_voll_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 GUI_1_voll
% Last Modified by GUIDE v2.5 05-Feb-2010 12:26:01
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @GUI_1_voll_OpeningFcn, ...
'gui_OutputFcn', @GUI_1_voll_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
ifnargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
% --- Executes just before GUI_1_voll is made visible. function GUI_1_voll_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 GUI_1_voll (see VARARGIN)
% Choose default command line output for GUI_1_voll
handles.output = hObject;
% UIWAIT makes GUI_1_voll wait for user response (see UIRESUME)
uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line. functionvarargout = GUI_1_voll_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 edit17_Callback(hObject, eventdata, handles) % hObject handle to edit17 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit17 as text % str2double(get(hObject,'String')) returns contents of edit17 as a double
% --- Executes during object creation, after setting all properties. function edit17_CreateFcn(hObject, eventdata, handles) % hObject handle to edit17 (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 edit18_Callback(hObject, eventdata, handles) % hObject handle to edit18 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit18 as text % str2double(get(hObject,'String')) returns contents of edit18 as a double
% --- Executes during object creation, after setting all properties. function edit18_CreateFcn(hObject, eventdata, handles) % hObject handle to edit18 (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 edit19_Callback(hObject, eventdata, handles) % hObject handle to edit19 (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 edit19 as text % str2double(get(hObject,'String')) returns contents of edit19 as a double
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end
% --- Executes during object creation, after setting all properties. function edit19_CreateFcn(hObject, eventdata, handles) % hObject handle to edit19 (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 edit20_Callback(hObject, eventdata, handles) % hObject handle to edit20 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit20 as text % str2double(get(hObject,'String')) returns contents of edit20 as a double
% --- Executes during object creation, after setting all properties. function edit20_CreateFcn(hObject, eventdata, handles) % hObject handle to edit20 (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 edit21_Callback(hObject, eventdata, handles) % hObject handle to edit21 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit21 as text % str2double(get(hObject,'String')) returns contents of edit21 as a double
% --- Executes during object creation, after setting all properties. function edit21_CreateFcn(hObject, eventdata, handles) % hObject handle to edit21 (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 edit22_Callback(hObject, eventdata, handles) % hObject handle to edit22 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit22 as text % str2double(get(hObject,'String')) returns contents of edit22 as a double
% --- Executes during object creation, after setting all properties. function edit22_CreateFcn(hObject, eventdata, handles) % hObject handle to edit22 (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 edit23_Callback(hObject, eventdata, handles) % hObject handle to edit23 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit23 as text % str2double(get(hObject,'String')) returns contents of edit23 as a double
% --- Executes during object creation, after setting all properties. function edit23_CreateFcn(hObject, eventdata, handles) % hObject handle to edit23 (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 edit24_Callback(hObject, eventdata, handles) % hObject handle to edit24 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit24 as text % str2double(get(hObject,'String')) returns contents of edit24 as a double
% --- Executes during object creation, after setting all properties. function edit24_CreateFcn(hObject, eventdata, handles) % hObject handle to edit24 (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 edit25_Callback(hObject, eventdata, handles) % hObject handle to edit25 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit25 as text % str2double(get(hObject,'String')) returns contents of edit25 as a double
% --- Executes during object creation, after setting all properties. function edit25_CreateFcn(hObject, eventdata, handles) % hObject handle to edit25 (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 edit26_Callback(hObject, eventdata, handles) % hObject handle to edit26 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit26 as text % str2double(get(hObject,'String')) returns contents of edit26 as a double
% --- Executes during object creation, after setting all properties. function edit26_CreateFcn(hObject, eventdata, handles) % hObject handle to edit26 (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 edit27_Callback(hObject, eventdata, handles) % hObject handle to edit27 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit27 as text % str2double(get(hObject,'String')) returns contents of edit27 as a double
% --- Executes during object creation, after setting all properties. function edit27_CreateFcn(hObject, eventdata, handles) % hObject handle to edit27 (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 edit28_Callback(hObject, eventdata, handles) % hObject handle to edit28 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit28 as text % str2double(get(hObject,'String')) returns contents of edit28 as a double
% --- Executes during object creation, after setting all properties. function edit28_CreateFcn(hObject, eventdata, handles) % hObject handle to edit28 (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 edit29_Callback(hObject, eventdata, handles) % hObject handle to edit29 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit29 as text % str2double(get(hObject,'String')) returns contents of edit29 as a double
% --- Executes during object creation, after setting all properties. function edit29_CreateFcn(hObject, eventdata, handles) % hObject handle to edit29 (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 edit30_Callback(hObject, eventdata, handles) % hObject handle to edit30 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit30 as text % str2double(get(hObject,'String')) returns contents of edit30 as a double
% --- Executes during object creation, after setting all properties. function edit30_CreateFcn(hObject, eventdata, handles) % hObject handle to edit30 (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 edit31_Callback(hObject, eventdata, handles) % hObject handle to edit31 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit31 as text % str2double(get(hObject,'String')) returns contents of edit31 as a double
% --- Executes during object creation, after setting all properties. function edit31_CreateFcn(hObject, eventdata, handles) % hObject handle to edit31 (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 edit32_Callback(hObject, eventdata, handles) % hObject handle to edit32 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit32 as text % str2double(get(hObject,'String')) returns contents of edit32 as a double
% --- Executes during object creation, after setting all properties. function edit32_CreateFcn(hObject, eventdata, handles) % hObject handle to edit32 (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 edit33_Callback(hObject, eventdata, handles) % hObject handle to edit33 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit33 as text % str2double(get(hObject,'String')) returns contents of edit33 as a double
% --- Executes during object creation, after setting all properties. function edit33_CreateFcn(hObject, eventdata, handles) % hObject handle to edit33 (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. function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) uiresume(handles.figure1);
x=str2double(get(handles.edit1, 'String'));
ausgabe{1}=x;
ausgabe{2}=y;
ausgabe{3}=z;
save tmp.mat ausgabe;
close;
Habe nun erstmal nur die ersten vier Werte mit ausgabe{ } versehen um zu testen, ob da überhaupt etwas passiert.
Wen wunderts, da tut sich nichts.
Drücke ich auf 'run', geht das Eingabefenster auf, das ist ja schonmal gut. Nur denke ich, dass dadurch dass in den callback buttons im GUI-Fenster noch nichts steht, die eingegebenen Werte nicht verarbeitet werden können. Stimmt das?
Was gibt mir denn der Befehl 'ausgabe' eigentlich aus?
Weisst du zufällig, wie man dann ein Programm erstellt, dass ohne in Matlab zu gehen nur über das GUI die Rechnungen durchführt (Matlab läuft also im Hintergrund)? Habe gehört, dass das gehen soll.
Dadurch, dass ich diesen Algorithmus präsentieren muss, kommt es meiner Meinung nach besser (weil optisch schöner und übersichtlicher), wenn der Benutzer nur die Oberfläche sieht und mit Matlab nichts zu tun hat.
Ok, da hab ich wohl etwas zu undurchsichtig geschrieben-
Nein an der OutputFcn liegt das nucht, die haben wir ja auf Eis gelegt. Wir machen das ja, indem wit eine temporäre Datei schreiben.
Die soll in unserem Fall ja nichts liefern.
ausgabe ist KEIN Befehl. Das war einfach der Name den cih der Variablen gegeben habe. Das ist der Name der Cell-Array-Variable und das was in geschweiften Klammern steht, ist die Position in dem Cell-Array. Also so, wie du in einer Matrix den Wert an einer bestimmten Position sehen kannst. Der Vorteil an Cell-Arrays ist, dass die unterschiedlcihen Einträge
nicht die gleiche Dimension haben müssen wie bei einer Matrix. Da muss ja jede Zeile die gleiche Anzahl Spalten haben. Das muss mein Cell-Array nicht sein. Du kannst da sogar in eine Position eine ganze Matrix reinschreiben.
x,y und z waren einfach nur Platzhalter um dir zu zeigen, wie die Methode funktioniert.
Da du viele Edit-Felder hast zeig ich dir mal als Beispiel wie du es auslesen könntest. Also in der
Code:
% --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) uiresume(handles.figure1);
Du weist einer Position der Variablen "variable" den Inhalt eines Edit-Feldes zu.
Natürlich musst du dann in der anderen Methode anstatt dem vorher benutzten "ausgabe" jetzt "variable" nehmen. Hast du nun kapiert was passiert?
Man kann in der Tat Matlabprogramme kompilieren um sie eigenständig laufen zu lassen. Habe ich aber noch nie gemacht und weiß nicht wie das geht. Du kannst das als extra Frage in die passende Rubrik schreiben. Vllt. gibt ja auch die Suche was her.
nun ist doch wieder aus unverständlichem Grund ein Problem aufgetreten.
Wollte ein paar Sachen umformulieren und auf einmal bekomme ich eine Fehlermeldung.
Das Programm läuft zwar trotzdem, aber befor es rechnet, bekomme ich die folgende Meldung:
Code:
??? Reference to non-existent field 'edit19'.
Error in ==> GUI_opti_cost_1>pushbutton1_Callback at 544
variable{3}=str2double(get(handles.edit19, 'String'));
Warning: The value of local variables may have been changed to match the
globals. Future versions of MATLAB will require that you declare
a variable to be global before you use that variable.
> In opti_cost at 9
Hier nochmal meine überarbeiteten beiden Dateien. Bin mir da recht sicher, dass irgendwo wieder mal ein kleiner Fehler von mir übersehen wurde.
Wäre super, wenn du mir dabei nochmal helfen könntest.
functionvarargout = GUI_opti_cost_1(varargin) % GUI_OPTI_COST_1 M-file for GUI_opti_cost_1.fig % GUI_OPTI_COST_1, by itself, creates a new GUI_OPTI_COST_1 or raises the existing % singleton*.
%
% H = GUI_OPTI_COST_1 returns the handle to a new GUI_OPTI_COST_1 or the handle to % the existing singleton*.
%
% GUI_OPTI_COST_1('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in GUI_OPTI_COST_1.M with the given input arguments.
%
% GUI_OPTI_COST_1('Property','Value',...) creates a new GUI_OPTI_COST_1 or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before GUI_opti_cost_1_OpeningFunction gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to GUI_opti_cost_1_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 GUI_opti_cost_1
% Last Modified by GUIDE v2.5 08-Feb-2010 21:42:43
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @GUI_opti_cost_1_OpeningFcn, ...
'gui_OutputFcn', @GUI_opti_cost_1_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
ifnargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
% --- Executes just before GUI_opti_cost_1 is made visible. function GUI_opti_cost_1_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 GUI_opti_cost_1 (see VARARGIN)
% Choose default command line output for GUI_opti_cost_1
handles.output = hObject;
% UIWAIT makes GUI_opti_cost_1 wait for user response (see UIRESUME)
uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line. functionvarargout = GUI_opti_cost_1_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_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)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % 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
function edit3_Callback(hObject, eventdata, handles) % hObject handle to edit3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit3 as text % str2double(get(hObject,'String')) returns contents of edit3 as a double
% --- Executes during object creation, after setting all properties. function edit3_CreateFcn(hObject, eventdata, handles) % hObject handle to edit3 (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 edit4_Callback(hObject, eventdata, handles) % hObject handle to edit4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit4 as text % str2double(get(hObject,'String')) returns contents of edit4 as a double
% --- Executes during object creation, after setting all properties. function edit4_CreateFcn(hObject, eventdata, handles) % hObject handle to edit4 (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 edit5_Callback(hObject, eventdata, handles) % hObject handle to edit5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit5 as text % str2double(get(hObject,'String')) returns contents of edit5 as a double
% --- Executes during object creation, after setting all properties. function edit5_CreateFcn(hObject, eventdata, handles) % hObject handle to edit5 (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 edit6_Callback(hObject, eventdata, handles) % hObject handle to edit6 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit6 as text % str2double(get(hObject,'String')) returns contents of edit6 as a double
% --- Executes during object creation, after setting all properties. function edit6_CreateFcn(hObject, eventdata, handles) % hObject handle to edit6 (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 edit7_Callback(hObject, eventdata, handles) % hObject handle to edit7 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit7 as text % str2double(get(hObject,'String')) returns contents of edit7 as a double
% --- Executes during object creation, after setting all properties. function edit7_CreateFcn(hObject, eventdata, handles) % hObject handle to edit7 (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 edit8_Callback(hObject, eventdata, handles) % hObject handle to edit8 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit8 as text % str2double(get(hObject,'String')) returns contents of edit8 as a double
% --- Executes during object creation, after setting all properties. function edit8_CreateFcn(hObject, eventdata, handles) % hObject handle to edit8 (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 edit9_Callback(hObject, eventdata, handles) % hObject handle to edit9 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit9 as text % str2double(get(hObject,'String')) returns contents of edit9 as a double
% --- Executes during object creation, after setting all properties. function edit9_CreateFcn(hObject, eventdata, handles) % hObject handle to edit9 (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 edit10_Callback(hObject, eventdata, handles) % hObject handle to edit10 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit10 as text % str2double(get(hObject,'String')) returns contents of edit10 as a double
% --- Executes during object creation, after setting all properties. function edit10_CreateFcn(hObject, eventdata, handles) % hObject handle to edit10 (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 edit11_Callback(hObject, eventdata, handles) % hObject handle to edit11 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit11 as text % str2double(get(hObject,'String')) returns contents of edit11 as a double
% --- Executes during object creation, after setting all properties. function edit11_CreateFcn(hObject, eventdata, handles) % hObject handle to edit11 (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 edit12_Callback(hObject, eventdata, handles) % hObject handle to edit12 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit12 as text % str2double(get(hObject,'String')) returns contents of edit12 as a double
% --- Executes during object creation, after setting all properties. function edit12_CreateFcn(hObject, eventdata, handles) % hObject handle to edit12 (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 edit13_Callback(hObject, eventdata, handles) % hObject handle to edit13 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit13 as text % str2double(get(hObject,'String')) returns contents of edit13 as a double
% --- Executes during object creation, after setting all properties. function edit13_CreateFcn(hObject, eventdata, handles) % hObject handle to edit13 (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 edit14_Callback(hObject, eventdata, handles) % hObject handle to edit14 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit14 as text % str2double(get(hObject,'String')) returns contents of edit14 as a double
% --- Executes during object creation, after setting all properties. function edit14_CreateFcn(hObject, eventdata, handles) % hObject handle to edit14 (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 edit15_Callback(hObject, eventdata, handles) % hObject handle to edit15 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit15 as text % str2double(get(hObject,'String')) returns contents of edit15 as a double
% --- Executes during object creation, after setting all properties. function edit15_CreateFcn(hObject, eventdata, handles) % hObject handle to edit15 (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 edit16_Callback(hObject, eventdata, handles) % hObject handle to edit16 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit16 as text % str2double(get(hObject,'String')) returns contents of edit16 as a double
% --- Executes during object creation, after setting all properties. function edit16_CreateFcn(hObject, eventdata, handles) % hObject handle to edit16 (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 edit17_Callback(hObject, eventdata, handles) % hObject handle to edit17 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit17 as text % str2double(get(hObject,'String')) returns contents of edit17 as a double
% --- Executes during object creation, after setting all properties. function edit17_CreateFcn(hObject, eventdata, handles) % hObject handle to edit17 (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 edit18_Callback(hObject, eventdata, handles) % hObject handle to edit18 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=str2double(get(hObject, 'String'));
ifisnan(a) set(hObject, 'String', 'NaN');
errordlg('Input must be a number','Error');
end % Hints: get(hObject,'String') returns contents of edit18 as text % str2double(get(hObject,'String')) returns contents of edit18 as a double
% --- Executes during object creation, after setting all properties. function edit18_CreateFcn(hObject, eventdata, handles) % hObject handle to edit18 (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. function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) uiresume(handles.figure1);
das edit-Feld Nr. 19 auslesen. Das gibt es aber in deinem GUI nicht. Bei 18 hört es auf.
Du brauchst entweder ein neues oder das wo du den Wert eingibst heißt anders.
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.