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

Erstellung eines Gui für Optimierungsaufgabe?

 

matlabpit
Forum-Anfänger

Forum-Anfänger


Beiträge: 24
Anmeldedatum: 27.01.10
Wohnort: ---
Version: 7.3
     Beitrag Verfasst am: 03.02.2010, 08:43     Titel: Erstellung eines Gui für Optimierungsaufgabe?
  Antworten mit Zitat      
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:



Code:
clc
clear all

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: ');

if op_typ==1
    Ea=input('Entry/lead angle: ');
elseif op_typ==2
    Ea=0;
else
    disp ('unknown');
end
entrance_angle=Ea*(pi/180);

Ca=5;           % Ca=input('Clearance angle: ');

clearance_angle=Ca*(pi/180);

Raat=2;         % Raat=input('surface roughness: ');

V=100;          % V=input('Starting value of velocity(mm/min): ');

f=0.05;         % f=input('Starting value of feedrate(mm/tooth): ');

C=837;          % C=input('Constant for cutting speed equation from table according to workpiece material: ');

p=1;            % p=input('Number of machining setups: ');

q=3;            % q=input('Number of machining operations: ');

% machine tool and overhead cost in EUR
c0=0.42;        % c0=input('machine and overhead cost: ');

% labor cost in Euro
c1=1.07/60;       % c1=input('labor cost in Euro: ')

ts=2;
ttc=0.5;
Kp=0.68;
E=0.9;


fixed_cost=p*((c0+c1)*ts)+q*((c0+c1)*ttc);

C2=(((c0+c1)*pi*d*K)/(1000*z));


if op_typ==1
    Q=(1/pi)*asin(arad/d);
elseif op_typ==2
    Q=(1/4)+((1/(2*pi))*asin(((2*arad)/d)-1));
elseif op_typ==3
    disp ('Error in input');
end

g=0.14;
w=0.28;
W=1.3;

% if cut_mat==1
%     n=0.275;
% elseif cut_mat==2
%     n=0.125;
% elseif cut_mat==3
%     n=0.6;
% else
%     disp('Unknown Cutter');
% end
n=0.15;

X1=(1/n)-1;                                
X2=((w+g)/n)-1;
X3=-(1/n);

C3=(ct)*((pi*d*K*Q*(5^(g/n))*C^X3)/(60000*z*(a^((g-w)/n))));

C4=((Kp*a*arad*z*W)/(60*pi*d*E*Pm));

if op_typ==1
    C6=318/((tan(entrance_angle)+cot(clearance_angle))*Raat);
else
    C5=(79.5/(d*Raat));
end

C7=(1000/(pi*d*8000));

x0=[V; f*1000];
A=[];
b=[];
Aeq=[];
beq=[];
lb=[0 0];
ub=[Inf Inf];
options=optimset('MaxFunEvals',50000,'MaxIter',5000,'Display','iter','Largescale','off');
if op_typ==1
    [x, machining_cost_for_operation]=fmincon(@fun1,x0,A,b,Aeq,beq,lb,ub,@nonlcon1,options)
else
    [x, machining_cost_for_operation]=fmincon(@fun1,x0,A,b,Aeq,beq,lb,ub,@nonlcon2,options)
end

x(2)=x(2)/1000;

machining_time=C2/((c0+c1)*x(1)*x(2))
% suggested_value_for_velocity=x(1)
% suggested_value_for_feedrate=x(2)
power_required_for_operation=C4*Pm*x(1)*x(2)*Cp
% end_milling_constraint=C5*Raat*x(2)^2
% face_milling_constraint=C6*Raat*x(2)
first_section_of_cost= C2*(x(1)^(-1))*(x(2)^(-1))
second_section_of_cost=C3*(x(1)^X1)*(x(2)^X2)
revolution_per_minute=x(1)*1000/(pi*d)




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

Vielen Dank schonmal für die Zeit und Hilfe

Gruß

Matlabpit
Private Nachricht senden Benutzer-Profile anzeigen


Hoorigaan
Forum-Anfänger

Forum-Anfänger


Beiträge: 15
Anmeldedatum: 18.12.09
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 03.02.2010, 10:29     Titel:
  Antworten mit Zitat      
Hi,

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;

durchmesser=str2double(get(handles.edit1, 'String'));

close;
 


Das close; beendet dein Gui.

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.
Private Nachricht senden Benutzer-Profile anzeigen
 
matlabpit
Themenstarter

Forum-Anfänger

Forum-Anfänger


Beiträge: 24
Anmeldedatum: 27.01.10
Wohnort: ---
Version: 7.3
     Beitrag Verfasst am: 03.02.2010, 21:46     Titel:
  Antworten mit Zitat      
Hallo Hoorigaan,

danke erstmal für die schnelle Antwort.

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.

Gruß

Matlabpit
Private Nachricht senden Benutzer-Profile anzeigen
 
Hoorigaan
Forum-Anfänger

Forum-Anfänger


Beiträge: 15
Anmeldedatum: 18.12.09
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 04.02.2010, 10:28     Titel: Antwort2
  Antworten mit Zitat      
Hallo,

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:
Code:

function varargout = test(varargin)
% End initialization code - DO NOT EDIT

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

% Update handles structure
guidata(hObject, handles);

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

% --- Outputs from this function are returned to the command line.
function varargout = 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
Code:
% uiwait(handles.figure1);

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
Code:
uiresume(handles.figure1);

reinschreibst. Dafür bietet sich z.B. ein Button an, der gedrückt werden soll, wenn die Eingaben gemacht sind.

Also mal ein Beispiel mit einem Eingabefeld und einem Knopf:
Code:

function varargout = test(varargin)
% End initialization code - DO NOT EDIT

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

% Update handles structure
guidata(hObject, handles);

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

% --- Outputs from this function are returned to the command line.
function varargout = 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.
if ispc && 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'));
if isnan(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.
Private Nachricht senden Benutzer-Profile anzeigen
 
matlabpit
Themenstarter

Forum-Anfänger

Forum-Anfänger


Beiträge: 24
Anmeldedatum: 27.01.10
Wohnort: ---
Version: 7.3
     Beitrag Verfasst am: 04.02.2010, 17:22     Titel:
  Antworten mit Zitat      
Hi Hoorigaan,

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.

Vielen Dank nochmal/schonmal

Matlabpit
Private Nachricht senden Benutzer-Profile anzeigen
 
Hoorigaan
Forum-Anfänger

Forum-Anfänger


Beiträge: 15
Anmeldedatum: 18.12.09
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 05.02.2010, 10:16     Titel:
  Antworten mit Zitat      
Hi,

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:

Code:

clc
clear all

Dein_GUI;
load tmp.mat

global fixed_cost C2 C3 X1 C5 C6 C4 X2 X3 C Cp C7 Pm;

In_GUI_gelesene_Variable=x;
...
...
 


Da du ja mehrere Variablen in deinem GUI einlesen willst, schlage ich die Speicherung in einem cell-Array vor. Also dann im GUI nicht:

save tmp.mat x;

Sondern:
Code:

ausgabe{1}=x;
ausgabe{2}=y;
ausgabe{3}=z;
save tmp.mat ausgabe;
 


dann kannst du in deinem Programm nämlich:
Code:

clc
clear all

Dein_GUI;
load tmp.mat

global fixed_cost C2 C3 X1 C5 C6 C4 X2 X3 C Cp C7 Pm;


d=ausgabe{1};
arad=ausgabe{2};    % arad=4;
a=ausgabe{3};        % a=4;
...
...
 


Falls nun die OutputFcn deines GUI aber ne Fehlermeldung bringt, dann setz einfach ein % vor das varargout{1}=handles.output.
Private Nachricht senden Benutzer-Profile anzeigen
 
matlabpit
Themenstarter

Forum-Anfänger

Forum-Anfänger


Beiträge: 24
Anmeldedatum: 27.01.10
Wohnort: ---
Version: 7.3
     Beitrag Verfasst am: 05.02.2010, 13:08     Titel:
  Antworten mit Zitat      
Hi,

verzweifle hier noch mit diesem Programm.

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.

Code:

% Fenster 1

clc
clear all

GUI_1_voll;
load tmp.mat

global fixed_cost C2 C3 X1 C5 C6 C4 X2 X3 C Cp C7 Pm Vektor Kosten;


d=ausgabe{1};       % d=input('Diameter of cutter: ');
a=ausgabe{2};    % arad=input('Radial Depth of Cut: ');    % arad=4;
arad=ausgabe{3};       % a=input('Axial Depth of Cut: ');        % a=4;
K=ausgabe{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: ');

if op_typ==1
    Ea=input('Entry/lead angle: ');
elseif op_typ==2
    Ea=0;
else
    disp ('unknown');
end
entrance_angle=Ea*(pi/180);

Ca=5;           % Ca=input('Clearance angle: ');

clearance_angle=Ca*(pi/180);

Raat=2;         % Raat=input('surface roughness: ');

V=100;          % V=input('Starting value of velocity(mm/min): ');

f=0.05;         % f=input('Starting value of feedrate(mm/tooth): ');

C=837;          % C=input('Constant for cutting speed equation from table according to workpiece material: ');

p=1;            % p=input('Number of machining setups: ');

q=3;            % q=input('Number of machining operations: ');

% machine tool and overhead cost in EUR
c0=0.42;        % c0=input('machine and overhead cost: ');

% labor cost in Euro
c1=1.07/60;       % c1=input('labor cost in Euro: ')

ts=2;
ttc=0.5;
Kp=0.68;
E=0.9;


fixed_cost=p*((c0+c1)*ts)+q*((c0+c1)*ttc);

C2=(((c0+c1)*pi*d*K)/(1000*z));


if op_typ==1
    Q=(1/pi)*asin(arad/d);
elseif op_typ==2
    Q=(1/4)+((1/(2*pi))*asin(((2*arad)/d)-1));
elseif op_typ==3
    disp ('Error in input');
end

g=0.14;
w=0.28;
W=1.3;

% if cut_mat==1
%     n=0.275;
% elseif cut_mat==2
%     n=0.125;
% elseif cut_mat==3
%     n=0.6;
% else
%     disp('Unknown Cutter');
% end
n=0.15;

X1=(1/n)-1;                                
X2=((w+g)/n)-1;
X3=-(1/n);

C3=(ct)*((pi*d*K*Q*(5^(g/n))*C^X3)/(60000*z*(a^((g-w)/n))));

C4=((Kp*a*arad*z*W)/(60*pi*d*E*Pm));

if op_typ==1
    C6=318/((tan(entrance_angle)+cot(clearance_angle))*Raat);
else
    C5=(79.5/(d*Raat));
end

C7=(1000/(pi*d*8000));

x0=[V; f*1000];
A=[];
b=[];
Aeq=[];
beq=[];
lb=[0 0];
ub=[1000 Inf];
options=optimset('MaxFunEvals',50000,'MaxIter',5000,'Display','iter','Largescale','off');
if op_typ==1
    [x, machining_cost_for_operation]=fmincon(@fun1,x0,A,b,Aeq,beq,lb,ub,@nonlcon1,options);
else
    [x, machining_cost_for_operation]=fmincon(@fun1,x0,A,b,Aeq,beq,lb,ub,@nonlcon2,options)
end

x(2)=x(2)/1000;

Vektor=x
Kosten=machining_cost_for_operation
machining_time=C2/((c0+c1)*x(1)*x(2))
% suggested_value_for_velocity=x(1)
% suggested_value_for_feedrate=x(2)
power_required_for_operation=C4*Pm*x(1)*x(2)*Cp
% end_milling_constraint=C5*Raat*x(2)^2
% face_milling_constraint=C6*Raat*x(2)
first_section_of_cost= C2*(x(1)^(-1))*(x(2)^(-1))
second_section_of_cost=C3*(x(1)^X1)*(x(2)^X2)
revolution_per_minute=x(1)*1000/(pi*d)
 




Code:

% Fenster Nebenbedingungen, Fall 1

function [constraints, empty] = nonlcon1(x)
global C6 C4 Cp C7 Pm;
x(2)=x(2)/1000;

if x(2)<= 0.02
    Cp=1.7;
elseif x(2)> 0.02 && x(2)<= 0.05
    Cp=1.4;
elseif x(2)> 0.05 && x(2)<= 0.07
    Cp=1.3;
elseif x(2)> 0.07 && x(2)<= 0.1
    Cp=1.25;
elseif x(2)> 0.1 && x(2)<= 0.12
    Cp=1.2;
elseif x(2)> 0.12 && x(2)<= 0.15
    Cp=1.15;
elseif x(2)> 0.15 && x(2)<= 0.18
    Cp=1.11;
elseif x(2)> 0.18 && x(2)<= 0.20
    Cp=1.08;
elseif x(2)> 0.20 && x(2)<= 0.22
    Cp=1.06;
elseif x(2)> 0.22 && x(2)<= 0.25
    Cp=1.04;
elseif x(2)> 0.25 && x(2)<= 0.28
    Cp=1.01;
elseif x(2)> 0.28 && x(2)<= 0.30
    Cp=1.00;
elseif x(2)> 0.30 && x(2)<= 0.33
    Cp=0.98;
elseif x(2)> 0.33 && x(2)<= 0.35
    Cp=0.97;
elseif x(2)> 0.35 && x(2)<= 0.38
    Cp=0.95;
elseif x(2)> 0.38 && x(2)<= 0.40
    Cp=0.94;
elseif x(2)> 0.40 && x(2)<= 0.45
    Cp=0.92;
elseif x(2)> 0.45 && x(2)<= 0.50
    Cp=0.90;
elseif x(2)> 0.55 && x(2)<= 0.60
    Cp=0.88;
elseif x(2)> 0.60 && x(2)<= 0.70
    Cp=0.87;
elseif x(2)> 0.70 && x(2)<= 0.80
    Cp=0.84;        
elseif x(2)> 0.80 && x(2)<= 0.90
    Cp=0.82;
elseif x(2)> 0.90 && x(2)<= 1.00
    Cp=0.80;
elseif x(2)> 1.00 && x(2)<= 1.50
    Cp=0.78;
else x(2)>= 1.50
    Cp=0.72;    
end

x(1)
x(2)

constraints(1)= (C4*x(1)*x(2)*Cp)-1          %power_constraint
constraints(2)= (C6*x(2))-1                  %surface constraint
constraints(3)= (C7*x(1))-1                  %revolution constraint
% constraints(4)= (60000*C4*x(2)*Cp*Pm)-1

empty=[];

 



Code:

% Fenster Nebenbedingungen Fall 2

function [constraints, empty] = nonlcon2(x)
global C5 C4 Cp C7 Pm;
x(2)=x(2)/1000;

if x(2)<= 0.02
    Cp=1.7;
elseif x(2)> 0.02 && x(2)<= 0.05
    Cp=1.4;
elseif x(2)> 0.05 && x(2)<= 0.07
    Cp=1.3;
elseif x(2)> 0.07 && x(2)<= 0.1
    Cp=1.25;
elseif x(2)> 0.1 && x(2)<= 0.12
    Cp=1.2;
elseif x(2)> 0.12 && x(2)<= 0.15
    Cp=1.15;
elseif x(2)> 0.15 && x(2)<= 0.18
    Cp=1.11;
elseif x(2)> 0.18 && x(2)<= 0.20
    Cp=1.08;
elseif x(2)> 0.20 && x(2)<= 0.22
    Cp=1.06;
elseif x(2)> 0.22 && x(2)<= 0.25
    Cp=1.04;
elseif x(2)> 0.25 && x(2)<= 0.28
    Cp=1.01;
elseif x(2)> 0.28 && x(2)<= 0.30
    Cp=1.00;
elseif x(2)> 0.30 && x(2)<= 0.33
    Cp=0.98;
elseif x(2)> 0.33 && x(2)<= 0.35
    Cp=0.97;
elseif x(2)> 0.35 && x(2)<= 0.38
    Cp=0.95;
elseif x(2)> 0.38 && x(2)<= 0.40
    Cp=0.94;
elseif x(2)> 0.40 && x(2)<= 0.45
    Cp=0.92;
elseif x(2)> 0.45 && x(2)<= 0.50
    Cp=0.90;
elseif x(2)> 0.55 && x(2)<= 0.60
    Cp=0.88;
elseif x(2)> 0.60 && x(2)<= 0.70
    Cp=0.87;
elseif x(2)> 0.70 && x(2)<= 0.80
    Cp=0.84;        
elseif x(2)> 0.80 && x(2)<= 0.90
    Cp=0.82;
elseif x(2)> 0.90 && x(2)<= 1.00
    Cp=0.80;
elseif x(2)> 1.00 && x(2)<= 1.50
    Cp=0.78;
else x(2)>= 1.50
    Cp=0.72;    
end

x(1)
x(2)

constraints(1)= (C4*x(1)*x(2)*Cp)-1          %power_constraint
constraints(2)= (C5*(x(2)^2))-1              %surface constraint
constraints(3)= (C7*x(1))-1                  %revolution constraint
% constraints(4)= (60000*C4*x(2)*Cp*Pm)-1

empty=[];
 



Code:

% Fenster Hauptfunktion


function objective_function = fun1(x)
global C2 C3 X1 X2;
x(2)=x(2)/1000;

objective_function = C2*x(1)^(-1)*x(2)^(-1)+C3*(x(1)^X1)*(x(2)^X2)

 



Code:

function varargout = 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',   []);
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 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;

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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.

Tausend Dank schonmal

Matlabpit
Private Nachricht senden Benutzer-Profile anzeigen
 
Hoorigaan
Forum-Anfänger

Forum-Anfänger


Beiträge: 15
Anmeldedatum: 18.12.09
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 06.02.2010, 12:53     Titel:
  Antworten mit Zitat      
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);

variable{1}=str2double(get(handles.edit1, 'String'));;
variable{2}=str2double(get(handles.edit2, 'String'));;
variable{3}=str2double(get(handles.edit3, 'String'));;

%und so weiter und so fort für alle Edit-Felder...

save tmp.mat variable;
close;
 

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.

Kannst ja bescheid sagen obs jetzt klappt.
Private Nachricht senden Benutzer-Profile anzeigen
 
matlabpit
Themenstarter

Forum-Anfänger

Forum-Anfänger


Beiträge: 24
Anmeldedatum: 27.01.10
Wohnort: ---
Version: 7.3
     Beitrag Verfasst am: 06.02.2010, 14:47     Titel:
  Antworten mit Zitat      
super.
Läuft.


Werde nun mal versuchen herauszufinden, wie man das Programm eigenständig zum Laufen bekommt, ohne über Matlab zu gehen.


Tausend Dank Dir
Private Nachricht senden Benutzer-Profile anzeigen
 
matlabpit
Themenstarter

Forum-Anfänger

Forum-Anfänger


Beiträge: 24
Anmeldedatum: 27.01.10
Wohnort: ---
Version: 7.3
     Beitrag Verfasst am: 08.02.2010, 22:04     Titel:
  Antworten mit Zitat      
Hi Hoorigaan,

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'));

Error in ==> gui_mainfcn at 75
        feval(varargin{:});

Error in ==> GUI_opti_cost_1 at 42
    gui_mainfcn(gui_State, varargin{:});

??? Error using ==> GUI_opti_cost_1('pushbutton1_Callback',gcbo,[],guidata(gcbo))
Reference to non-existent field 'edit19'.

??? Error using ==> waitfor
Error while evaluating uicontrol Callback

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.




Code:
function opti_cost

clc
clear all

GUI_opti_cost_1;
load tmp.mat

global fixed_cost C2 C3 X1 C5 C6 C4 X2 X3 C Cp C7 N Pm Vektor Kosten variable;


d=variable{1};          
a=variable{2};
arad=variable{3};      
K=variable{4};  
N=variable{5};
op_typ=variable{6};
cut_mat=variable{7};
Ca=variable{9};
z=variable{10};
Pm=variable{11};
Raat=variable{12};
C=variable{13};
% n=variable{14};
Kp=variable{15};
c1=variable{16};
c0=variable{17};
ct=variable{18};


if op_typ==1
    Ea=variable{8};
elseif op_typ==2
    Ea=0;
else
    disp ('unknown');
end

entrance_angle=Ea*(pi/180);
clearance_angle=Ca*(pi/180);

V=100;          % V=input('Starting value of velocity(mm/min): ');

f=0.05;         % f=input('Starting value of feedrate(mm/tooth): ');

p=1;            % p=input('Number of machining setups: ');

q=3;            % q=input('Number of machining operations: ');

% machine tool and overhead cost in EUR 0.42
% c0=input('machine and overhead cost: ');

% labor cost in Euro 0.02
% c1=input('labor cost in Euro: ')

ts=2;
ttc=0.5;
E=0.9;


fixed_cost=p*((c0+c1)*ts)+q*((c0+c1)*ttc);

C2=(((c0+c1)*pi*d*K)/(1000*z));


if op_typ==1
    Q=(1/pi)*asin(arad/d);
elseif op_typ==2
    Q=(1/4)+((1/(2*pi))*asin(((2*arad)/d)-1));
elseif op_typ==3
    disp ('Error in input');
end


g=0.14;
w=0.28;
W=1.3;

if cut_mat==1
    n=0.275;
elseif cut_mat==2
    n=0.125;
elseif cut_mat==3
    n=0.6;
else
    disp('Unknown Cutter');
end


X1=(1/n)-1;                                
X2=((w+g)/n)-1;
X3=-(1/n);

C3=(ct)*((pi*d*K*Q*(5^(g/n))*C^X3)/(60000*z*(a^((g-w)/n))));

C4=((Kp*a*arad*z*W)/(60*pi*d*E*Pm));

if op_typ==1
    C6=318/((tan(entrance_angle)+cot(clearance_angle))*Raat);
else
    C5=(79.5/(d*Raat));
end

C7=(1000/(pi*d*N));

x0=[V; f*1000];
A=[];
b=[];
Aeq=[];
beq=[];
lb=[0 0];
ub=[1000 Inf];
options=optimset('MaxFunEvals',50000,'MaxIter',5000,'Display','iter','Largescale','off');
if op_typ==1
    [x, machining_cost_for_operation]=fmincon(@fun1,x0,A,b,Aeq,beq,lb,ub,@nonlcon1,options);
else
    [x, machining_cost_for_operation]=fmincon(@fun1,x0,A,b,Aeq,beq,lb,ub,@nonlcon2,options)
end

x(2)=x(2)/1000;

Vektor=x
Kosten=machining_cost_for_operation
machining_time=C2/((c0+c1)*x(1)*x(2))
% suggested_value_for_velocity=x(1)
% suggested_value_for_feedrate=x(2)
power_required_for_operation=C4*Pm*x(1)*x(2)*Cp
% end_milling_constraint=C5*Raat*x(2)^2
% face_milling_constraint=C6*Raat*x(2)
first_section_of_cost= C2*(x(1)^(-1))*(x(2)^(-1))
second_section_of_cost=C3*(x(1)^X1)*(x(2)^X2)
revolution_per_minute=x(1)*1000/(pi*d)




Code:
function varargout = 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',   []);
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 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;

% Update handles structure
guidata(hObject, handles);

% 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.
function varargout = 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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'));
if isnan(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.
if ispc && 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);

variable{1}=str2double(get(handles.edit17, 'String'));
variable{2}=str2double(get(handles.edit18, 'String'));
variable{3}=str2double(get(handles.edit19, 'String'));
variable{4}=str2double(get(handles.edit20, 'String'));
variable{5}=str2double(get(handles.edit21, 'String'));
variable{6}=str2double(get(handles.edit22, 'String'));
variable{7}=str2double(get(handles.edit23, 'String'));
variable{8}=str2double(get(handles.edit24, 'String'));
variable{9}=str2double(get(handles.edit25, 'String'));
variable{10}=str2double(get(handles.edit26, 'String'));
variable{11}=str2double(get(handles.edit27, 'String'));
variable{12}=str2double(get(handles.edit28, 'String'));
variable{13}=str2double(get(handles.edit29, 'String'));
% variable{14}=str2double(get(handles.edit30, 'String'));
variable{15}=str2double(get(handles.edit31, 'String'));
variable{16}=str2double(get(handles.edit32, 'String'));
variable{17}=str2double(get(handles.edit33, 'String'));
variable{18}=str2double(get(handles.edit34, 'String'));
x=str2double(get(handles.edit1, 'String'));

save tmp.mat variable;
close;

 
Private Nachricht senden Benutzer-Profile anzeigen
 
Hoorigaan
Forum-Anfänger

Forum-Anfänger


Beiträge: 15
Anmeldedatum: 18.12.09
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 09.02.2010, 13:14     Titel: Antwort
  Antworten mit Zitat      
Die Lösung ist ganz simpel.

Liegt in deinem GUI.

Du möchtest in der Zeile
Code:
variable{3}=str2double(get(handles.edit19, 'String'));

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.
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 - 2024 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.