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

Wert aus GUI-Funktion im Hauptprogramm verwenden

 

qais
Forum-Newbie

Forum-Newbie


Beiträge: 1
Anmeldedatum: 12.08.17
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 12.08.2017, 21:44     Titel: Wert aus GUI-Funktion im Hauptprogramm verwenden
  Antworten mit Zitat      
Hallo,
ich habe folgendes Problem, an dem ich nun Stunden sitze.

Ich möchte in einem GUI-Fenster ein Bild (unter axes angezeigt) aussuchen und je nach Bild den Wert map = 1, 2 oder 3 speichern, damit ich es im Hauptprogramm weiter verwenden kann.

Der Code des GUIs ist der folgende:

Code:

function varargout = MapAuswahl(varargin)


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

% Last Modified by GUIDE v2.5 12-Aug-2017 21:18:56

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

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

axes(handles.bild1);
imshow('Map1.jpg');

axes(handles.bild2);
imshow('Map2.jpg');

axes(handles.bild3);
imshow('Map3.jpg');

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = MapAuswahl_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 map1.
function map1_Callback(hObject, eventdata, handles,mapWahl)
% hObject    handle to map1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
mapWahl = 1;
% Hint: get(hObject,'Value') returns toggle state of map1


% --- Executes on button press in map2.
function map2_Callback(hObject, eventdata, handles,mapWahl)
% hObject    handle to map2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
mapWahl = 2;
% Hint: get(hObject,'Value') returns toggle state of map2


% --- Executes on button press in map3.
function map3_Callback(hObject, eventdata, handles,mapWahl)
% hObject    handle to map3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global mapWahl;
mapWahl = 3;
% Hint: get(hObject,'Value') returns toggle state of map3


% --- Executes on button press in weiter.
function weiter_Callback(hObject, eventdata, handles, mapWahl)
% hObject    handle to weiter (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

close;
Private Nachricht senden Benutzer-Profile anzeigen


Harald
Forum-Meister

Forum-Meister


Beiträge: 24.448
Anmeldedatum: 26.03.09
Wohnort: Nähe München
Version: ab 2017b
     Beitrag Verfasst am: 12.08.2017, 22:38     Titel:
  Antworten mit Zitat      
Hallo,

was ist das "Hauptprogramm", und in welchem Bezug steht es zur GUI?
Es klingt so, als ob das Problem die Verwaltung von Daten in einer GUI wäre. Dann siehe
https://de.mathworks.com/help/matla.....data-among-callbacks.html
Grüße,
Harald
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.