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

Parameter mit GUI einlesen und an Funktion übergeben

 

Mr.Wayne
Forum-Newbie

Forum-Newbie


Beiträge: 2
Anmeldedatum: 19.04.14
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 19.04.2014, 11:10     Titel: Parameter mit GUI einlesen und an Funktion übergeben
  Antworten mit Zitat      
Hallo zusammen,
ich bin MATLAB Anfänger und würde gerne mit einem einfachen GUI einen Parameter in ein "edit text" Feld eintragen und mit einem "push button" soll die Funktion gestartet werden, aber auch der Parameter aus dem "edit text" soll in der Funktion verwendet werden.

Die Funktion kann ich bereits mit dem "push button" auslösen:
Berechnung_Heizverlauf_3(P_Zyl_1,P_Zyl_2,P_Zyl_3,P_Zyl_4,V)
Jetzt würde aber gerne den Parameter aus der Box übergeben. Hier der Code:

Code:
function varargout = GUI_Heizverlauf(varargin)
% GUI_HEIZVERLAUF MATLAB code for GUI_Heizverlauf.fig
%      GUI_HEIZVERLAUF, by itself, creates a new GUI_HEIZVERLAUF or raises the existing
%      singleton*.
%
%      H = GUI_HEIZVERLAUF returns the handle to a new GUI_HEIZVERLAUF or the handle to
%      the existing singleton*.
%
%      GUI_HEIZVERLAUF('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in GUI_HEIZVERLAUF.M with the given input arguments.
%
%      GUI_HEIZVERLAUF('Property','Value',...) creates a new GUI_HEIZVERLAUF or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before GUI_Heizverlauf_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to GUI_Heizverlauf_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_Heizverlauf

% Last Modified by GUIDE v2.5 19-Apr-2014 12:05:23

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @GUI_Heizverlauf_OpeningFcn, ...
                   'gui_OutputFcn',  @GUI_Heizverlauf_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_Heizverlauf is made visible.
function GUI_Heizverlauf_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_Heizverlauf (see VARARGIN)

% Choose default command line output for GUI_Heizverlauf
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = GUI_Heizverlauf_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)

% 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


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


Kann mit jemand weiterhelfen?
Vielen Dank!
Private Nachricht senden Benutzer-Profile anzeigen


Harald
Forum-Meister

Forum-Meister


Beiträge: 24.495
Anmeldedatum: 26.03.09
Wohnort: Nähe München
Version: ab 2017b
     Beitrag Verfasst am: 19.04.2014, 19:02     Titel:
  Antworten mit Zitat      
Hallo,

welche "Box"? Das editierbare Textfeld? Dessen Inhalt bekommst du mit
Code:
get(handles.edit1,'String')


Grüße,
Harald
Private Nachricht senden Benutzer-Profile anzeigen
 
Mr.Wayne
Themenstarter

Forum-Newbie

Forum-Newbie


Beiträge: 2
Anmeldedatum: 19.04.14
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 24.04.2014, 20:40     Titel:
  Antworten mit Zitat      
Hallo Harald,
vielen herzlichen Dank für Deine Hilfe! Ich hab mein Problem lösen können. Ich kann jetzt über die Eingabe von Werte in eine "Edit Text" Box eines GUI Werte einlesen und in den Workspace als Parameter setzen...
Hier mein Programmcode, falls das jemandem helfen sollte:
Code:
function varargout = untitled1(varargin)
% UNTITLED1 MATLAB code for untitled1.fig
%      UNTITLED1, by itself, creates a new UNTITLED1 or raises the existing
%      singleton*.
%
%      H = UNTITLED1 returns the handle to a new UNTITLED1 or the handle to
%      the existing singleton*.
%
%      UNTITLED1('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in UNTITLED1.M with the given input arguments.
%
%      UNTITLED1('Property','Value',...) creates a new UNTITLED1 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before untitled1_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to untitled1_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 untitled1

% Last Modified by GUIDE v2.5 20-Apr-2014 21:48:45

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @untitled1_OpeningFcn, ...
                   'gui_OutputFcn',  @untitled1_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 untitled1 is made visible.
function untitled1_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 untitled1 (see VARARGIN)

% Choose default command line output for untitled1
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = untitled1_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 Glaettung_Callback(hObject, eventdata, handles)
% hObject    handle to Glaettung (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 Glaettung as text
%        str2double(get(hObject,'String')) returns contents of Glaettung as a double


% --- Executes during object creation, after setting all properties.
function Glaettung_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Glaettung (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 AddOneTag.
function AddOneTag_Callback(hObject, eventdata, handles)
% hObject    handle to AddOneTag (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
GL=get(handles.Glaettung,'String');
GL=str2double(GL);
assignin('base','GL',GL);
BSW=get(handles.Berechnungsschrittweite,'String');
BSW=str2double(BSW);
assignin('base','BSW',BSW);
ASP=get(handles.Arbeitsspiele,'String');
ASP=str2double(ASP);
assignin('base','ASP',ASP);

%set(handles.Glaettung,'String',num2str(a))



function Berechnungsschrittweite_Callback(hObject, eventdata, handles)
% hObject    handle to Berechnungsschrittweite (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 Berechnungsschrittweite as text
%        str2double(get(hObject,'String')) returns contents of Berechnungsschrittweite as a double


% --- Executes during object creation, after setting all properties.
function Berechnungsschrittweite_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Berechnungsschrittweite (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 Arbeitsspiele_Callback(hObject, eventdata, handles)
% hObject    handle to Arbeitsspiele (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 Arbeitsspiele as text
%        str2double(get(hObject,'String')) returns contents of Arbeitsspiele as a double


% --- Executes during object creation, after setting all properties.
function Arbeitsspiele_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Arbeitsspiele (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 ML_Callback(hObject, eventdata, handles)
% hObject    handle to ML (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 ML as text
%        str2double(get(hObject,'String')) returns contents of ML as a double
ML=get(handles.ML,'String');
ML=str2double(ML);
assignin('base','ML',ML);


% --- Executes during object creation, after setting all properties.
function ML_CreateFcn(hObject, eventdata, handles)
% hObject    handle to ML (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 Lambda_Callback(hObject, eventdata, handles)
% hObject    handle to Lambda (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 Lambda as text
%        str2double(get(hObject,'String')) returns contents of Lambda as a double
Lambda=get(handles.Lambda,'String');
Lambda=str2double(Lambda);
assignin('base','Lambda',Lambda);

% --- Executes during object creation, after setting all properties.
function Lambda_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Lambda (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 MBE_Callback(hObject, eventdata, handles)
% hObject    handle to MBE (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 MBE as text
%        str2double(get(hObject,'String')) returns contents of MBE as a double
MBE=get(handles.MBE,'String');
MBE=str2double(MBE);
assignin('base','MBE',MBE);

% --- Executes during object creation, after setting all properties.
function MBE_CreateFcn(hObject, eventdata, handles)
% hObject    handle to MBE (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

Viele Grüße
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.