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

% Last Modified by GUIDE v2.5 05-May-2011 15:31:53

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

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

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = Test_check_popup_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 Laden.
function Laden_Callback(hObject, eventdata, handles)
% hObject    handle to Laden (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
%Datei einlesen:

%Windows-Explorer öffenen!
[xlsfile,path2xls] = uigetfile ('*.xls', 'Bitte wählen');
%Einlesen der Excel-Tabelle!
rawdata1 = xlsread(fullfile(path2xls,xlsfile)); 
%Definition als Zeilenvektor
m1 = [rawdata1(:,1);rawdata1(:,2)];
%Bestimmen der Zeilenanzahl
z1 = length(m1)/2;
%Definition der m x n Matrix
m1 = reshape(m1,z1,2);

%Definition der Trendlinie

%Definition der X-Achse
m1_x = m1(:,2); 
%Definition der Y-Achse
m1_y = m1(:,1);             
%m und n für Geradengleichung
geradenwerte1 = polyfit (log(m1_x), log(m1_y), 2);
%x-Intervall für Geradengleichung
m1_xi = log(0:500);   
%Werte der Geradengleichung
gerade1 = polyval(geradenwerte1, m1_xi);  


%Grafik einbinden

%hold on;
%Dartsetllung der Punkte
%handles.m1_p = loglog(m1_x, m1_y, 'b*');
%zunächst nicht sichtabr machen
%set(handles.m1_p, 'visible', 'off');
%Darstellung der Geraden
%handles.m1_l = loglog(exp(m1_xi), exp(gerade1), 'b');
%zunächst nicht sichtabr machen
%set(handles.m1_l, 'visible', 'off');
%hold off;


%Daten übertragen

handles.m1_x = m1_x;
handles.m1_y = m1_y;
handles.m1_xi = m1_xi;
handles.gerade1 = gerade1;

guidata(hObject, handles);

% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu1

m1_x = handles.m1_x;
m1_y = handles.m1_y;
m1_xi = handles.m1_xi;
gerade1 = handles.gerade1;


%Nummer des ausgewählten Menu-Eintrages
val = get (hObject, 'Value');
%Lister der Pop-up-Menu-Einträge (Cell-Arry)
str = get (hObject, 'String');

%Text zur Nummer des ausgewählten Menu-Eintrags
switch(str{val})
    %Eintrag Punkte wurde ausgewählt -> Darstellung Punkte
    case 'Punkte'
        %Dartsetllung der Punkte
        handles.m1_p = loglog(m1_x, m1_y, 'b*');
        %zunächst nicht sichtabr machen
        set(handles.m1_p, 'visible', 'off');
    case 'Linie'
        %Darstellung der Geraden
        handles.m1_l = loglog(exp(m1_xi), exp(gerade1), 'b');
        %zunächst nicht sichtabr machen
        set(handles.m1_l, 'visible', 'off');
end
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% 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


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

% Hint: get(hObject,'Value') returns toggle state of checkbox1
if get (hObject, 'value') ==1
    set(handles.m1_p, 'visible', 'on');
    set(handles.m1_l, 'visible', 'on');
elseif get(hObject, 'Value') ==0
    set(handles.m1_p, 'visible', 'off');
    set(handles.m1_l, 'visible', 'off');
end

guidata(hObject, handles);