function varargout = GrafikWahl(varargin)
% GRAFIKWAHL M-file for GrafikWahl.fig

% Last Modified by GUIDE v2.5 29-Jan-2007 13:38:40

% Begin initialization code - DO NOT EDIT
   gui_Singleton = 1;
   gui_State = struct('gui_Name',       mfilename, ...
                      'gui_Singleton',  gui_Singleton, ...
                      'gui_OpeningFcn', @GrafikWahl_OpeningFcn, ...
                      'gui_OutputFcn',  @GrafikWahl_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 GrafikWahl is made visible.
function GrafikWahl_OpeningFcn(hObject, eventdata, handles, varargin)
   % Choose default command line output for GrafikWahl
   handles.output = hObject;
   
   handles.Startwert = 0;
   handles.Endwert   = 2 * pi;
   handles.Grafiktyp = 'sin';
   
   set( handles.edit1, 'String', handles.Startwert );
   set( handles.edit2, 'String', handles.Endwert );

   % Update handles structure
   guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = GrafikWahl_OutputFcn(hObject, eventdata, handles) 
   % Get default command line output from handles structure
   varargout{1} = handles.output;


% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
   % Hints: contents = get(hObject,'String') returns popupmenu1 contents as cell array
   %        contents{get(hObject,'Value')} returns selected item from popupmenu1

   % Nummer des ausgewählten Menü-Eintrags 
   val = get( hObject, 'Value' ); 
   % Liste der Texte im Pop-up-Menü (Cell-Array) 
   str = get( hObject, 'String' ); 
   
   handles.Grafiktyp = str{val};
   
   guidata(hObject,handles)
   
   plotGrafik( handles )


% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
   % Hint: popupmenu 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 edit1_Callback(hObject, eventdata, handles)
   % Hints: get(hObject,'String') returns contents of edit1 as text
   %        str2double(get(hObject,'String')) returns contents of edit1 as a double
   handles.Startwert = str2double( get(hObject,'String') );
   guidata(hObject,handles);

   plotGrafik( handles )
   
   
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
   % 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 edit2_Callback(hObject, eventdata, handles)
   % Hints: get(hObject,'String') returns contents of edit2 as text
   %        str2double(get(hObject,'String')) returns contents of edit2 as a double
   handles.Endwert = str2double( get(hObject,'String') );
   guidata(hObject,handles);
   
   plotGrafik( handles );


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


% Grafik-Ausgabe   
function  plotGrafik( handles )   
   % Text zur Nummer des ausgewählten Menü-Eintrags 
   switch( handles.Grafiktyp ) 
      % Eintrag sin wurde ausgewählt 
      case 'sin' 
         fplot( 'sin', [handles.Startwert,handles.Endwert] ); 
      % Eintrag cos wurde ausgewählt 
      case 'cos' 
         fplot( 'cos', [handles.Startwert,handles.Endwert] ); 
      % Eintrag exp wurde ausgewählt 
      case 'exp' 
         fplot( 'exp', [handles.Startwert,handles.Endwert] ); 
   end

