image thumbnail

shape analysis of oscillations

by

 

Analysis the of shape of sinusoidal osczillations by interpreting the peaks in the Fourier spectrum.

main_window.m
%% harmonics detection/characterization of sinusoidal signals with Fourier analysis - main_window.m
% Abstract:  
%   This program allows you to analyze the change over time of significant 
%   frequencies of an oscillation with a fast Fourier transformation-analysis.
%   The oscillation data can be imported from files with ascii-formatted
%   data. With the tool you can evaluate lots of files fast and
%   easy in little steps.
%   There are many possibilities to prepare and analyze the data. The
%   preparation includes noise reduction with window-functions or BLUBB as 
%   well as average determination.
%   As input information you only need the sampling rate of your incoming
%   data and the stimulating frequency of the oscillation. 
%   At start you choose which frequencies of your oscillation you want to
%   evaluate by clicking on them in the plot of the Fourier transformation.
%   As result you get a fit which contains peak-height, -position and noise 
%   (and some more). The program displays and saves the change of these 
%   parameters over all selected files. You get the results as txt-files 
%   and can observe the progress in different plots.
% 
%   In this short Overview the main functions are shown to you:
%   <http://youtu.be/g47iaagzK0o>
% 
%
%   Hint: GUI appearance is optimized for Windows 7 Aero Style! The style
%   of GUI elements is not checked on other OS layouts!
%
% Version:          0.2
% Release date:     2012-05-04
% Author:           Matthias Funk, Sven Meister
% Matlab Version:   R2011b
%
% Acknowledgements:
%   This application is based on the idea and code of Matthias Funk from
%   the Karlsruhe Institute of Technology (KIT), IAM-WBM, Nachwuchsgruppe 
%   fr microreliability. This project was financed by DFG-SFB499N01.
%
% 
% *Content:*
% 
% (to switch into the parts directly, click on the name behind the colon 
%  on the right-hand side and hit CTRL+D)
% -------------------------------------------------------------------------
%   1. GUI initalisation:       main_window
%      1.1. Close Request:      figure1_CloseRequestFcn
%      1.2. Config File:        set_config
%      1.3. Language settings:  change_language
%
%   2. GUI appearence:          PUM_fit_Callback
%
%   3. GUI Callbacks:           
%      3.1. Settings:           EDIT_open_oeffnen_Callback
%      3.2. Plot control:
%         3.2.1. File content:  SLID_sin_x_Callback
%         3.2.1. Pause:         EDIT_pause_Callback
%         3.2.1. fit plot:      PB_fft_plus_Callback
%         3.2.1. fit results:   AXES_peakhoehe_ButtonDownFcn
%
%   4. Main function:
%      4.1. Start:              PB_start_Callback
%      4.2. Plot file content:	cm_axes_anzeigen_Callback
%
%   5. Menu Callbacks:          
%      5.1. File:               menu_datei_neu_Callback
%      5.2. Edit:               menu_bearbeiten_mitteln_Callback
%      5.3. View:               menu_anzeige_figure_Callback
%      5.4. Options:            menu_optionen_pause_Callback
%      5.5. Help:               menu_hilfe_ueber_Callback
% -------------------------------------------------------------------------

%% most important elements in this code:
% - control flow:
%    the program is user-controlled by Callbacks of GUI elements. The user
%    takes settings and presses 'start'. Then main function routine starts.
% - config.txt
%    on startup the tool tries to load configuration data from the file
%    config.txt. That file has to be in die main folder


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

% Last Modified by GUIDE v2.5 30-Sep-2011 17:11:13

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @main_window_OpeningFcn, ...
                   'gui_OutputFcn',  @main_window_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
%-saves filepath of main_window.m to config_dir as location for the
% config-file used @set_config
global config_dir
FuncFile = mfilename('fullpath');
config_dir = fileparts(FuncFile); 

% --- Executes just before main_window is made visible.
function main_window_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 main_window (see VARARGIN)

% load config.txt/set last data-directory 
% to see, which row contains which data: have a look @set_config
  %  global config_dir
  %  cd(config_dir)
    [fid,msg] = fopen('config.txt');
  %  disp(msg)
    if isempty(msg)
        content = textscan(fid,'%s','delimiter',';');
        fclose(fid);
        config = content{1};
        if (isdir(char(config(1)))) && (isdir(char(config(2))))
            set(handles.EDIT_open_oeffnen,'String',char(config(1)));
            set(handles.EDIT_open_ergebnisse,'String',char(config(2)));
            cd(char(config(1))) % set current folder
        end
        set(handles.EDIT_fs,'String',char(config(3)));   % FS
        set(handles.EDIT_af,'String',char(config(4)));   % AF
        set(handles.EDIT_ahh,'String',char(config(5)));  % AHH
        handles.language.kind = char(config(6));         % Language  
    else
        handles.language.kind = 'FFT_English.txt';
    end
% set icons on buttons
    set(handles.PB_open_oeffnen,'CData',double(imread('open_icon.bmp'))/255);
    set(handles.PB_open_ergebnisse,'CData',double(imread('open_icon.bmp'))/255);
%Standartwerte: (veraltet)
    handles.zeilen = 15000;
    handles.fs = 250;
    handles.af = 10;
    handles.gf = 20;
    handles.anzahl = 1;
    handles.anzGF = 1;
    handles.cutoff = 50;
    handles.spalte = 1;
    handles.count_sin = 1;
    handles.count_fft = 1;
    handles.count_width = 1;
    handles.anz_Dateien = 0;
    
% set language    
%     handles = change_language('FFT_German.txt',handles);
    handles = change_language(handles.language.kind,handles);
    
% plot first graph of folder if possible
    if (isdir(char(config(1)))) && (isdir(char(config(2)))) 
        set(handles.SLID_sin_x,'Visible','on');
       % set(handles.SLID_sin_x2,'Visible','on','Max',handles.zeilen);
        cm_axes_anzeigen_Callback(handles.PB_open_oeffnen, eventdata, handles)
    end
    
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = main_window_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 when user attempts to close figure.
function figure1_CloseRequestFcn(hObject, eventdata, handles)
    %-config.txt aktualisieren
    set_config(hObject, handles);
    %-Subplot-Figure schlieen
    if (get(handles.CB_subplot,'Value')==1) && (ishandle(handles.handle_subplot)) 
        delete(handles.handle_subplot);
    end
    %-anzGF-Figure schlieen
    if (str2num(get(handles.EDIT_anzGF,'String'))>1) && (ishandle(handles.handle_anzGF))
        delete(handles.handle_anzGF);
    end
    %-Hauptfenster schlieen
    delete(hObject);


%% Config.txt file --------------------------------------------------------
function set_config(hObject, handles)
    %% set_config
    % stores user-settings to a text-file in main-Directory of the program
    % Order of settings (# LineNumber):
    % #1 input-folder
    % #2 output-folder
    % #3 Sampling-Rate
    % #4 anregende Frequenz
    % #5 anzahl hherer Harmonischer
    %
    % config.txt is read here: main_window_OpeningFcn

    %-save settings
    global config_dir
    cd(config_dir)
    fid = fopen('config.txt','w');  % overwrites old file..
    %-folder
    dir_in = get(handles.EDIT_open_oeffnen,'String');
    dir_out = get(handles.EDIT_open_ergebnisse,'String');
    if (~strcmp(dir_in,'')) && (~strcmp(dir_in,'0'))
        fprintf(fid,'%s;\n',dir_in);
        fprintf(fid,'%s;\n',dir_out);
    else
        fprintf(fid,'%s;\n',['Z:' filesep 'noDirSelected' filesep]);
        fprintf(fid,'%s;\n',['Z:' filesep 'noDirSelected' filesep]);
    end
    %-Values
    fprintf(fid,'%s;\n',num2str(get(handles.EDIT_fs,'String')));
    fprintf(fid,'%s;\n',num2str(get(handles.EDIT_af,'String')));
    fprintf(fid,'%s;\n',num2str(get(handles.EDIT_ahh,'String')));
    fprintf(fid,'%s;\n',handles.language.kind);
    %-close file
    fclose(fid);

    
%% Change Language --------------------------------------------------------
function handles = change_language(file, handles)
    global config_dir
    Strings = sprachPaket_lesen(config_dir,file);   %[config_dir sep 'languages']
    % main_window
    set(gcf,'Name',Strings.main_window.Name);
    % menu
    menu = fieldnames(Strings.menu);
    for n = 1:length(menu)
        set(handles.(char(menu(n))),'Label',char(Strings.menu.(char(menu(n)))));
    end
    % labels
    labels = fieldnames(Strings.labels);
    for n = 1:length(labels)
        set(handles.(char(labels(n))),'String',char(Strings.labels.(char(labels(n)))));
    end
    % tooltips
    tooltips = fieldnames(Strings.tooltips);
    for n = 1:length(tooltips)
        set(handles.(char(tooltips(n))),'TooltipString',char(Strings.tooltips.(char(tooltips(n)))));
    end
    % dialog_boxes
    db.filein = Strings.dialog_boxes.filein;
    db.fileout = Strings.dialog_boxes.fileout;
    db.yes = Strings.dialog_boxes.yes;
    db.no = Strings.dialog_boxes.no;
    db.save = Strings.dialog_boxes.save;
    db.FT_save = Strings.dialog_boxes.FT_save;
    handles.language.db = db;
    % plots
    plots.xlabel_sin = Strings.plots.xlabel_sin;
    plots.file = Strings.plots.file;
    plots.titlefft1 = Strings.plots.titlefft1;
    plots.titlefft2 = Strings.plots.titlefft2;
    plots.column_pum = Strings.plots.column_pum;
    handles.language.plots = plots;
    % kind
    handles.language.kind = file;
    
function menu_sprache_english_Callback(hObject, eventdata, handles)
    handles = change_language('FFT_English.txt',handles);
    guidata(hObject, handles);

function menu_sprache_german_Callback(hObject, eventdata, handles)
    handles = change_language('FFT_German.txt',handles);
    guidata(hObject, handles);

    
%% GUI appearence ---------------------------------------------------------
function PUM_fit_Callback(hObject, eventdata, handles)
    switch get(hObject,'Value')
        case 2
            set(handles.CB_subplot,'Visible','on');
            set([handles.TEXT_anzGF,handles.EDIT_anzGF,...
                handles.PB_anzGF_plus,handles.PB_anzGF_minus],'Enable','on')
        case 4
            set(handles.CB_subplot,'Visible','off');
            set([handles.TEXT_anzGF,handles.EDIT_anzGF,...
                handles.PB_anzGF_plus,handles.PB_anzGF_minus],'Enable','off')
        otherwise
            set(handles.CB_subplot,'Visible','off');
            set([handles.TEXT_anzGF,handles.EDIT_anzGF,...
                handles.PB_anzGF_plus,handles.PB_anzGF_minus],'Enable','on')
    end
    guidata(hObject, handles);
    
        
%% Callbacks of GUI elements ----------------------------------------------
% Settings:
function EDIT_open_oeffnen_Callback(hObject, eventdata, handles)
    handles.fi=get(handles.EDIT_open_oeffnen,'String');
    if ~strcmp(get(handles.EDIT_open_oeffnen,'String'),'0')
        set({handles.AXES_sin,handles.SLID_sin_x},'Visible','on'); 
        set(handles.SLID_sin_x2,'Visible','on','Max',handles.zeilen);
        cm_axes_anzeigen_Callback(handles.PB_open_oeffnen, eventdata, handles)
    end
    guidata(hObject, handles);
    
    
function EDIT_open_ergebnisse_Callback(hObject, eventdata, handles)
    handles.fo=get(handles.EDIT_open_oeffnen,'String');;
    guidata(hObject, handles);

    
function PB_open_oeffnen_Callback(hObject, eventdata, handles)
%     filein = uigetdir('','Aus welchem Verzeichnis soll bearbeitet werden?');
    filein = uigetdir('',handles.language.db.filein);
    if ischar(filein) && isdir(filein)
        set(handles.EDIT_open_oeffnen,'String',filein);
        handles.fi=filein;
        set(handles.AXES_sin,'Visible','on'); 
        set(handles.SLID_sin_x,'Visible','on');
%         set(handles.SLID_sin_x2,'Visible','on','Max',handles.zeilen);
        cm_axes_anzeigen_Callback(hObject, eventdata, handles)
        guidata(hObject, handles);
    end

    
function PB_open_ergebnisse_Callback(hObject, eventdata, handles)
%     fileout= uigetdir('','In welches Verzeichnis sollen die Ergebnisse gespeichert werden?');
    fileout= uigetdir('',handles.language.db.fileout);
    if ischar(fileout) && isdir(fileout)
%         handles.E = dir (fileout);
        set(handles.EDIT_open_ergebnisse,'String',fileout);
        handles.fo = fileout;
        guidata(hObject, handles);
    end
       
    
function PB_open_newFolder_Callback(hObject, eventdata, handles)
% creates a new folder in the parentFolder of the data directory called
% '../Results/<Date__Time>'
    %-get parentFolder of data directory:----------------------------------
    filein = get(handles.EDIT_open_oeffnen,'String');  % get data directory
    [parentFolder, name, ext] = fileparts(filein);
    %-get date+time--------------------------------------------------------
    c = fix(clock);
    date = sprintf('%u-%02u-%02u__%02u-%02u-%02u',c);
    %-check, weather data is allready from Ergebnisse-folder
    [pF, name_pF, ext_pF] = fileparts(parentFolder);
    if strcmp(name_pF,'Results')
        newFolder = [parentFolder filesep date];
    else
        newFolder = [parentFolder filesep 'Results' filesep date];
    end
    %-create new folder and set resultFolder to the newly created----------
    mkdir(newFolder);
    set(handles.EDIT_open_ergebnisse,'String',newFolder);


function PUM_spalte_Callback(hObject, eventdata, handles)
spa = get(hObject,'Value');
handles.spalte = spa;
cm_axes_anzeigen_Callback(hObject, eventdata, handles)
guidata(hObject, handles);


function PB_anzahl_plus_Callback(hObject, eventdata, handles)
    anz = get(handles.EDIT_anzahl,'String');
    global anzahl_Dateien
    %anzD = handles.anz_Dateien;
    if str2num(anz) < anzahl_Dateien
        set(handles.EDIT_anzahl,'String',num2str(str2num(anz)+1));
    else
        set(handles.EDIT_anzahl,'String','1');
    end
    guidata(hObject, handles);

    
function PB_anzahl_minus_Callback(hObject, eventdata, handles)
    anz = get(handles.EDIT_anzahl,'String');
    global anzahl_Dateien
    if str2num(anz)>1
        set(handles.EDIT_anzahl,'String',num2str(str2num(anz)-1));
    else
        set(handles.EDIT_anzahl,'String',num2str(anzahl_Dateien));
    end
    guidata(hObject, handles);

    
function EDIT_anzGF_Callback(hObject, eventdata, handles)
    if str2num(get(hObject,'String'))>7
        set(hObject,'String','7');
    end
    if str2num(get(hObject,'String'))<1
        set(hObject,'String','1');
    end
    if str2num(get(hObject,'String'))>1
        set(handles.CB_subplot,'Enable','off','Value',0);
    else set(handles.CB_subplot,'Enable','on');
    end   
    guidata(hObject, handles);

    
function PB_anzGF_plus_Callback(hObject, eventdata, handles)
    anz = get(handles.EDIT_anzGF,'String');
    if str2num(anz)<7
        set(handles.EDIT_anzGF, 'String',num2str(str2num(anz)+1));
    end
    if str2num(get(handles.EDIT_anzGF,'String'))>1
        set(handles.CB_subplot,'Enable','off','Value',0);
    else set(handles.CB_subplot,'Enable','on');
    end   
    guidata(hObject, handles);

    
function PB_anzGF_minus_Callback(hObject, eventdata, handles)
    anz = get(handles.EDIT_anzGF,'String');
    if str2num(anz)>1
        set(handles.EDIT_anzGF, 'String',num2str(str2num(anz)-1));
    end
    if str2num(get(handles.EDIT_anzGF,'String'))>1
        set(handles.CB_subplot,'Enable','off','Value',0);
    else set(handles.CB_subplot,'Enable','on');
    end   
    guidata(hObject, handles);

    
function EDIT_fs_Callback(hObject, eventdata, handles)
    handles.fs = str2num(get(hObject,'String'));
    guidata(hObject, handles);

    
function EDIT_af_Callback(hObject, eventdata, handles)
    handles.af = str2num(get(hObject,'String'));
    guidata(hObject, handles);

    
function EDIT_gf_Callback(hObject, eventdata, handles)
    handles.gf = str2num(get(hObject,'String'));
    guidata(hObject, handles);

    
function EDIT_zeilen_Callback(hObject, eventdata, handles)
    handles.zeilen = str2num(get(hObject,'String'));
    set(handles.SLID_sin_x2,'Max',handles.zeilen);
    cm_axes_anzeigen_Callback(hObject, eventdata, handles)
    guidata(hObject, handles);

    
function EDIT_cutoff_Callback(hObject, eventdata, handles)
    handles.cutoff = str2num(get(hObject,'String'));
    guidata(hObject, handles);
    
    
function PUM_rauschen_Callback(hObject, eventdata, handles)
    switch get(hObject,'Value')
        case 1
           % set(handles.CB_subplot,'Visible','on');
            set([handles.TEXT_anzGF,handles.EDIT_anzGF,...
                handles.PB_anzGF_plus,handles.PB_anzGF_minus],'Enable','off')
            set([handles.EDIT_cutoff,handles.ST_cutoff],'Enable','on')
        otherwise
           % set(handles.CB_subplot,'Visible','off');
            set([handles.TEXT_anzGF,handles.EDIT_anzGF,...
                handles.PB_anzGF_plus,handles.PB_anzGF_minus],'Enable','on')
            set([handles.EDIT_cutoff,handles.ST_cutoff],'Enable','off')
    end
    guidata(hObject, handles);


% -------------------------------------------------------------------------
% Plot control (file content):
function SLID_sin_x_Callback(hObject, eventdata, handles)
    zei = str2num(get(handles.EDIT_zeilen,'String'));
    val = get(hObject,'Value');
    lim = [0 zei*val];
    set(handles.AXES_sin,'XLim',lim);
    %set(handles.SLID_sin_x2,'Max',15000-lim(2)); %Value mit verndern, wenn max < value?
    guidata(hObject, handles);

function PB_sin_plus_Callback(hObject, eventdata, handles)
    cm_axes_anzeigen_Callback(hObject, eventdata, handles)

function PB_sin_minus_Callback(hObject, eventdata, handles)
    cm_axes_anzeigen_Callback(hObject, eventdata, handles)
   
function SLID_sin_x2_Callback(hObject, eventdata, handles)
    max = get(hObject,'Max');
    val = get(hObject,'Value');
    lim1 = handles.zeilen * get(handles.SLID_sin_x,'Value');
    lim = [val val+lim1];
    set(handles.AXES_sin,'XLim',lim);
    guidata(hObject, handles);
        
    
% -------------------------------------------------------------------------
% Plot control (pause):
function EDIT_pause_Callback(hObject, eventdata, handles)
    set(handles.SLIDER_pause,'Value',str2num(get(handles.EDIT_pause,'String')));

function SLIDER_pause_Callback(hObject, eventdata, handles)
    set(handles.EDIT_pause,'String',num2str(get(hObject,'Value')));
    drawnow
    guidata(hObject, handles);

 
% -------------------------------------------------------------------------
% Plot control (results/ fit display):   
function PB_fft_plus_Callback(hObject, eventdata, handles)
    count = handles.count_fft;
    anz = str2num(get(handles.EDIT_anzahl,'String'));
    AF = str2num(get(handles.EDIT_af,'String'));
    GF = handles.GF;
    switch hObject
        case handles.PB_fft_plus
            if count < anz
                count = count + 1;
            end
        case handles.PB_fft_minus
            if count > 1
                count = count - 1;
            end
    end 
    fit_data = handles.fit_datas{count};
    xdata = fit_data{1};
    ydata = fit_data{2};
    ytest = fit_data{3};
    
    axes(handles.AXES_fft)
    semilogy(xdata,ydata); 
    hold on
	semilogy(xdata,ytest,'black');
    title1 = get(handles.PUM_spalte,'String');
    title([char(title1(get(handles.PUM_spalte,'Value'))),...
    	': peakfitting - Datei ',num2str(count)]);
    grid on
    xlabel('frequency [Hz]');
    ylabel('paekintensity');
    xlim(handles.xlim_fit);
    ylim([0.000001 0.2]);
    hold off
    
    handles.count_fft = count;    
    guidata(hObject, handles);

    
function PB_fft_minus_Callback(hObject, eventdata, handles)
    PB_fft_plus_Callback(hObject, eventdata, handles)


% -------------------------------------------------------------------------
% Plot control (results/ parameter):
function AXES_peakhoehe_ButtonDownFcn(hObject, eventdata, handles)
    % you can display the results of peak-position of every GF in an own
    % limits-range. To switch between the GFs you have to click into the
    % axes while peak-position is selected
    if get(handles.PUM_peak,'Value') == 2
        anzGF = str2num(get(handles.EDIT_anzGF,'String'));  
        count = handles.count_width; 
        axes(handles.AXES_peakhoehe);    
        xfit = handles.xfit{1};
        if count < anzGF
            count = count + 1;
        else
            count = 1;
        end
        handles.count_width = count;
        ylim([0.995*xfit{count}(2) 1.005*xfit{count}(2)])        
        show_Legend(handles)
    end
    guidata(hObject, handles);

    
function PUM_peak_Callback(hObject, eventdata, handles)
    % displays the different xfit-parameters selected bei the Pop-Up-Menu
    axes(handles.AXES_peakhoehe);
    anz = str2num(get(handles.EDIT_anzahl,'String'));
    anzGF = str2num(get(handles.EDIT_anzGF,'String'));   
    count = handles.count_width;
    
    for i=1:anz
        xfit = handles.xfit{i};
        for j=1:anzGF
            if (i==1) && (j==1)
                hold off
            else
                hold on
            end
            xfit_parameter_anzeigen(handles,xfit,i,j,count);
        end
    end
    if get(handles.CB_grid,'Value')==1
            grid on; else
            grid off;
    end
    xlim([0 anz+1]);
    xlabel('Datei');
    show_Legend(handles)
    set(handles.AXES_peakhoehe,'ButtonDownFcn',@(hObject,eventdata)main_window('AXES_peakhoehe_ButtonDownFcn',hObject,eventdata,guidata(hObject)))
    guidata(hObject, handles);
   
    
function xfit_parameter_anzeigen (handles,xfit,i,j,count) 
    % switch between xfit-parameters 
    plotcolor = ['b','m','k','r','g','y','c'];
    switch get(handles.PUM_peak,'Value')
            	case 1
                	plot(i,xfit{j}(1),[plotcolor(j),'o']) 
                    if i>1
                        yl = get(gca,'YLim'); 
                        ylim([min(0.95*xfit{j}(1),yl(1)) max(1.05*xfit{j}(1),yl(2))])  
                    end
                case 2
                    plot(i,xfit{j}(2),[plotcolor(j),'o'])    
                  %  disp(count)
                    ylim([0.9995*xfit{count}(2) 1.0005*xfit{count}(2)])
                           % ylim([xfit{1}(2)-0.005 xfit{1}(2)+0.005]);
                case 3
                    plot(i,xfit{j}(3),[plotcolor(j),'o'])    
                    if i>1
                        yl = get(gca,'YLim');
                        ylim([min(0.99*xfit{j}(3),yl(1)) max(1.01*xfit{j}(3),yl(2))])
                    end
                case 4
                    semilogy(i,xfit{j}(4),[plotcolor(j),'o'])                            
                    m = mean(xfit{1}(4));                            
                    ylim([m/2 2*m])
                           % ylim([xfit{1}(4)/2 xfit{1}(4)*2]);  
                case 5
                	plot(i,xfit{j}(5),[plotcolor(j),'o'])         
                    if i>1
                        yl = get(gca,'YLim'); 
                        ylim([min(0.95*xfit{j}(5),yl(1)) max(1.05*xfit{j}(5),yl(2))])
                    end
    end
    
    
function CB_grid_Callback(hObject, eventdata, handles)
    % displays a grid in parameter-plot
    axes(handles.AXES_peakhoehe)
    grid
    
% 
% function PB_nextPlot_Callback(hObject, eventdata, handles)
%   %  if get(handles.PUM_peak,'Value') == 2
%    %     PUM_peak_Callback(hObject, eventdata, handles)        
%     %end
%     
%     anzGF = str2num(get(handles.EDIT_anzGF,'String'));  
%     count = handles.count_width; 
%     axes(handles.AXES_peakhoehe);
%     
%         xfit = handles.xfit{1};
%         if count < anzGF
%             count = count + 1;
%         else
%             count = 1;
%         end
%         handles.count_width = count;
%     ylim([0.995*xfit{count}(2) 1.005*xfit{count}(2)])
%     
%     guidata(hObject, handles);




    
%% Main Code
% this is the main functionality of this program.
function PB_start_Callback(hObject, eventdata, handles)
    % initial values:
    filein = get(handles.EDIT_open_oeffnen,'String');
    fileout = get(handles.EDIT_open_ergebnisse,'String');
  %  zeilen = str2num(get(handles.EDIT_zeilen,'String'));
  %  spalte = get(handles.PUM_spalte,'Value');
  %  AF = str2num(get(handles.EDIT_af,'String'));
    GF(1) = str2num(get(handles.EDIT_gf,'String'));
  %  fs = str2num(get(handles.EDIT_fs,'String'));
    anz = str2num(get(handles.EDIT_anzahl,'String'));   % Anzahl Dateien
    xmin = 0;
    xmax = 0;
    x_GFmin(1) = 0;  x_GFmax(1) = 0; % Startwert fr Ort der gesuchten Frequenz in Datenpunkten
    xfit{1}=[0.0005 20 0.006 0.00001];
    frage = 'Nein'; % Startwert, ob FT-Spektren gespeichert werden sollen
    SGFD = 0;
    plotcolor = ['b','m','k','r','g','y','c'];
    wid = 1;
    handles.count_sin = 0;
    
    D = dir(filein);
    
    % waitbar auf 0% anzeigen
    wbtxt = sprintf('\t[%s%s]\t',char('#'*ones(1,0)),char('_'*ones(1,30)));
    wbpro = sprintf('%3.0f%%',0);
    set(handles.TEXT_wb,'String',['Progress:   ',wbtxt,wbpro]);
    
    % open new figure for subplots, if option is selected
    if get(handles.CB_subplot,'Value') == 1
        hp = figure('Name','xfit-Parameter',...
            'Units','normalized','Position',[0.01 0.1 0.25 0.8]);
        handles.handle_subplot = hp;
        guidata(hObject, handles);
    end
    
    % open new figure to plot progress of all GF in subplots
    anzGF = str2num(get(handles.EDIT_anzGF,'String'));
    if (anzGF > 1) && (get(handles.PUM_fit,'Value')~=1)
        hg = figure('Name','fit-Kurven',...
            'Units','normalized','Position',[0.04 0.1 0.25 0.8]);
        handles.handle_anzGF = hg;
        guidata(hObject, handles);
    end
      
    % repeat process for each file
    for i = 1:anz
        F = getfield(D,{2+i,1},'name'); % 2+i because first two values in D are '.' and ','
        cd (filein)
        data=importdata(F);
        if isfield(data,'data') % if there is a header, importdata creates fields 'textdata' (header) and 'data'
            data = data.data;
        end
    
        %% fft_fit_GUI
        [handles,peakhoehe,FT,xmin,xmax,x_GFmin,x_GFmax,xfit,GF,SGFD,fit_data,wid] = fft_fit_GUI(handles,data,i,xmin,xmax,x_GFmin,x_GFmax,xfit,GF,SGFD,wid);        
        
        %% Waitbar progress
        wb = fix(i/anz*30);
        wbtxt = sprintf('\t[%s%s]\t',char('#'*ones(1,wb)),char('_'*ones(1,30-wb))); 
        wbpro = sprintf('%3.0f%%',i/anz*100);
        set(handles.TEXT_wb,'String',['Progress:   ',wbtxt,'  ',wbpro]);
    
        %% plot results of fit
        set(handles.AXES_peakhoehe,'Visible','on');
        axes(handles.AXES_peakhoehe)
        hold on
        switch get(handles.PUM_fit,'Value')
            case 1 %-max----
                for r=1:anzGF
                    plot(i,peakhoehe(r),'o')               
                    title('peakintensity')
                    ylim([peakhoehe(anzGF)-0.01 peakhoehe(1)+0.01])       % berarbeiten? Flexibleren Mastab whlen
                end
            case 2 %-xfit----
                set([handles.PUM_peak,handles.CB_grid],'Visible','on');
                
               %-Subplot in extra Fenster fr xfit-Paramter:--------------
                if get(handles.CB_subplot,'Value') == 1
                    figure(hp)
                   %-Peakhoehe-------------
                    subplot(2,2,1)
                    hold on
                    plot(i,xfit{1}(1),'o')
                    hold off
                    ylim([xfit{1}(1)-0.01 xfit{1}(1)+0.01])
                    title('peakintensity');
                    xlim([0 anz+1])
                    grid on
                   %-Peakposition----------
                    subplot(2,2,2)
                    hold on
                    plot(i,xfit{1}(2),'o')
                    hold off
                    ylim([xfit{1}(2)-0.005 xfit{1}(2)+0.005]);
                    title('peakposition')
                    ylabel('frequency [Hz]');
                    xlim([0 anz+1])
                    grid on
                   %-Peakbreite------------
                    subplot(2,2,3)
                    hold on
                    plot(i,abs(xfit{1}(3)),'o')
                    hold off
                    ylim([abs(xfit{1}(3))*0.92 abs(xfit{1}(3))*1.08]);
                    title('peakwidth');
                    xlim([0 anz+1])
                    grid on
                   %-Rauschen--------------
                    subplot(2,2,4)
                    hold on
                    semilogy(i,xfit{1}(4),'o')
                    hold off
                    ylim([xfit{1}(4)/2 xfit{1}(4)*2]);
                    title('peaknoise');
                    xlim([0 anz+1])
                    grid on
                   %-FT-Spektrum----------- 
                end
                %----------------------------------------------------------                
                axes(handles.AXES_peakhoehe)
                grid off
                for r=1:anzGF
                    xfit_parameter_anzeigen(handles,xfit,i,r,1)
                end
                handles.fit_datas{i} = fit_data;    % Daten der fit-Kurve in neuem cell-Array in handles speichern
                handles.xfit{i} = xfit;
                % handles.xfit{i} ist ein mehrdimensionales cell-Array:
                %   handles.xfit{<NrDatei>}{<NrFrequenz>}(<NrFit-Parameter>)
            case 3 %-max (x) & xfit(o)----
                for r = 1:anzGF
                    plot(i,peakhoehe(r),[plotcolor(r),'x'])    % max-Funktion
                    plot(i,xfit{r}(1),[plotcolor(r),'o'])      % xfit(1)
                    title('peakintensity')
                    m = mean(xfit{1}(1));
                    ylim([min(xfit{anzGF}(1))-0.25*m max(xfit{1}(1))+0.25*m])
                end
            case 4 %-Integral----
                for r = 1:anzGF
                    plot(i,xfit{r}(1),[plotcolor(r),'o'])   % area
                    title('area')
                  %  m = mean(xfit{1}(1));
                  %  ylim([xfit{1}(1)-0.25*m xfit{1}(1)+0.25*m])
                end
        end
        %-Legende einfgen-----------------------------------------
        if (i == 1) && (get(handles.PUM_fit,'Value')~=4)
            handles.GF = GF;
            show_Legend(handles)
        end
        %----------------------------------------------------------
        hold off
        xlim([0 anz+1]) % extend limits after every file
        
        drawnow
        
        %% Dateien fr Spektrum aufzeichnen
        cd(fileout)
        if i == 1   % i := filecount
            frage = questdlg(handles.language.db.FT_save,handles.language.db.save,handles.language.db.yes,handles.language.db.no,handles.language.db.yes);
        end
        if strcmp(frage,'Ja')
            dlmwrite(['FT-spektrum',num2str(i),'.txt'], FT, 'delimiter','\t');
        end        
    
        switch get(handles.PUM_fit,'Value')
            case {1,2,3}
                for r=1:anzGF
                    % Dateien fr peakhoehe aufzeichnen
                    dlmwrite(['peakhoeheGF',num2str(r),'.txt'], peakhoehe(r) , 'delimiter', '\t', '-append');
                    %  Dateien fr peakposition aufzeichnen
                    dlmwrite(['peakpositionGF',num2str(r),'.txt'], xfit{r}(2) , 'delimiter', '\t', '-append');
                    %  Dateien fr xfit(1) aufzeichnen
                    dlmwrite(['xfit1_GF',num2str(r),'.txt'], xfit{r}(1) , 'delimiter', '\t', '-append');
                    %  Dateien fr Flche unter Peak aufzeichnen
                    dlmwrite(['peakflche_GF',num2str(r),'.txt'], xfit{r}(5) , 'delimiter', '\t', '-append');
                end
            case 4
                %  Dateien fr Flche aufzeichnen
                dlmwrite(['area',num2str(r),'.txt'], xfit{1}(1) , 'delimiter', '\t', '-append');
        end
        %-Pause------------------------------------------------------------
        % gives the user the chance to have a look on the fit to evaluate
        % it. Pause-time can be reduced, because if the fit is good, it
        % should work for all following files.
        if ((get(handles.PUM_fit,'Value')==2) || (get(handles.PUM_fit,'Value')==3))...
                && (str2num(get(handles.EDIT_pause,'String'))~=0) && (i<anz)
            switch get(handles.menu_optionen_pause,'Checked')
                case 'on'
                    col = get(gcf,'Color');
                    condition = true;
                    axes(handles.AXES_pause)
                    plot([0,1],[0,0],'r','LineWidth',2)
                    t0 = cputime;
                    n = 0;
                    while (condition)
                        n = n+1;
                        t = str2num(get(handles.EDIT_pause,'String'));
                        t1 = cputime;
                        delta = (t1-t0)/t;
                        if delta >= 1
                            condition = false;
                        end
                        hold off
                        plot([0,delta],[0,0],'g','LineWidth',5)
                        hold on
                        plot([delta,1],[0,0],'r','LineWidth',3)
                        xlim([0 1]);
                        set(gca,'Color',col,'XColor',col,'YColor',col);
                        drawnow
                    end
                case 'off'
                    pause(str2num(get(handles.EDIT_pause,'String')));
            end %switch
            disp(n)
        end %if
    end %for
    
    % control elements for plot of xfit-parameters
    if get(handles.PUM_fit,'Value') == 2
        set([handles.PUM_peak,handles.CB_grid],'Enable','on');
        set([handles.PB_fft_plus,handles.PB_fft_minus],'Visible','on');
     %   handles.xfit1 = xfit1;      % Werte speichern, um sie spter wieder zu plotten
     %   handles.xfit2 = xfit2;
     %   handles.xfit3 = xfit3;
     %   handles.xfit4 = xfit4;
        handles.count_fft = anz;
       % whos handles.xfit
    end
    if get(handles.PUM_fit,'Value') == 3
        handles.count_fft = anz;
        set([handles.PB_fft_plus,handles.PB_fft_minus],'Visible','on');
    end
    handles.GF = GF;
    %% Ende
    guidata(hObject, handles);

% display file data
function cm_axes_anzeigen_Callback(hObject, eventdata, handles)
    set(handles.PB_sin_plus,'Visible','on');
    set(handles.PB_sin_minus,'Visible','on');
    filein = get(handles.EDIT_open_oeffnen,'String');
    zeilen = str2num(get(handles.EDIT_zeilen,'String'));
    spalte = get(handles.PUM_spalte,'Value');
    count = handles.count_sin;
    anz = str2num(get(handles.EDIT_anzahl,'String'));
    D = dir(filein);
   if size(D,1) > 2 % checks, weather there are files in D or not
    switch hObject
        case handles.PB_sin_plus
            if count < anz
                count = count + 1;
            end
        case handles.PB_sin_minus
            if count > 1
                count = count - 1;
            end
    end
    F = getfield(D,{2+count,1},'name');
    cd (filein)
    data=importdata(F);
    if isfield(data,'data') % wenn input einen header besitzt (see doc input)
        data = data.data;
    end
    
    if hObject == handles.PB_open_oeffnen
        % Lnge von data bestimmen und als Default-Wert setzen;
        [zeilen,spalten] = size(data);
        set(handles.EDIT_zeilen,'String',num2str(zeilen));
        % Anzahl Spalten bestimmen/in PUM schreiben
        for n = 1:spalten
            string_spalte{n} = [handles.language.plots.column_pum,' ' num2str(n)];
        end
        set(handles.PUM_spalte,'String',string_spalte);
        % Anzahl Dateien im Ordner bestimmen
        handles.anz_Dateien = length(D) - 2;
        global anzahl_Dateien
        anzahl_Dateien = length(D) - 2;
        %anzD = handles.anz_Dateien
    end
    x=data(1:zeilen,spalte);
    if hObject==handles.menu_anzeige_figure
        hf = figure('Name','',...   
                    'Units','pixels');
    else
        axes(handles.AXES_sin)
    end
    label = get(handles.PUM_spalte,'String');
    plot(x);
    xlabel(handles.language.plots.xlabel_sin);
    label2 = [handles.language.plots.file,' ',num2str(count),': ',char(label(get(handles.PUM_spalte,'Value')))];
    if hObject==handles.menu_anzeige_figure
        set(hf,'Name',label2);
    else
        title(label2);
        xlim([0 zeilen*get(handles.SLID_sin_x,'Value')]);
    end
    handles.count_sin = count;
   end 
    guidata(gcf, handles);
        
function show_Legend(handles)
    GF = handles.GF;
    anzGF = str2num(get(handles.EDIT_anzGF,'String'));    
    for i = 1:anzGF
        leg{i} = [num2str(round(GF(i))),' Hz'];
    end
    hleg = legend(leg);
    set(hleg,'FontSize',8)
      
    


    
%% Menu
% File --------------------------------------------------------------------
function menu_datei_neu_Callback(hObject, eventdata, handles)
    a = questdlg({'Unsaved progress will be lost!';'';'Are you sure?'},'New','Yes','No','Yes'); % Sichterheitsabfrage
    if strcmp(a,'Yes')
        %-config.txt aktualisieren
        set_config(hObject, handles);
        %-evtl. offene Fenster schlieen
        if (get(handles.CB_subplot,'Value')==1) && (ishandle(handles.handle_subplot))
            delete(handles.handle_subplot);
        end
        if (str2num(get(handles.EDIT_anzGF,'String'))>1) && (ishandle(handles.handle_anzGF))
            delete(handles.handle_anzGF);
        end
        delete(handles.figure1);
        hold off
        main_window   % GUI neu starten
    end

function menu_datei_beenden_Callback(hObject, eventdata, handles)
%Beenden-Button im Datei-Men
    a = questdlg('Really quit?','','Yes','No','Yes'); %Sichterheitsabfrage
    if strcmp(a,'Yes')
        %-config.txt aktualisieren
        set_config(hObject, handles);
        %-evtl. offene Fenster schlieen
        if (get(handles.CB_subplot,'Value')==1) && (ishandle(handles.handle_subplot))
            delete(handles.handle_subplot);
        end
        if (str2num(get(handles.EDIT_anzGF,'String'))>1) && (ishandle(handles.handle_anzGF))
            delete(handles.handle_anzGF);
        end
        delete(handles.figure1);  %Fenster schlieen
    end
    
      
% Edit --------------------------------------------------------------------
function menu_bearbeiten_mitteln_Callback(hObject, eventdata, handles)
% This function calculates the mean of d datapoints in the selected column and
% saves results in a new file into the results folder
    d = str2num(char(inputdlg('Wieviele Werte sollen gemittelt werden?','Mitteln')));
    filein = get(handles.EDIT_open_oeffnen,'String');
    fileout = get(handles.EDIT_open_ergebnisse,'String');
    spalte = get(handles.PUM_spalte,'Value');
    count = handles.count_sin;
    take_d = 0; % Boolean, ob Anzahl zu mittelnder Werte bernommen wird
    condition_spalte = 1;
    while condition_spalte
        D = dir(filein);
        F = getfield(D,{2+count,1},'name');
        cd (filein)
        daten=importdata(F);  
        if isfield(daten,'data')
            daten = daten.data;
        end
        cd(fileout)
        daten=daten(:,spalte);
        d_ges = 1;  % speichert die gesamte Anzahl der Mittelungen
        condition_anzahl = 1;
        while condition_anzahl
            d_ges = d_ges * d;
            l=length(daten);
            abschnitte=l/d;
            %dlmwrite('abschnitt.txt',abschnitte);   % Wozu?
            laenge=d*floor(abschnitte);
            datenneu=daten(1:laenge,1);
            B=reshape(datenneu,d,floor(abschnitte));
            % dlmwrite('B.txt',B, 'delimiter', '\t');
            B=B';
            A=mean(B,2);
            hf = figure('Name','Gemittelte Werte: Zum Fortfahren dieses Fenster schlieen',...   
                        'Units','pixels');
            plot(A);
            uiwait(hf)  % warten, bis hf geschlossen wurde
            if take_d == 0
                ans1 = questdlg('erneute Mittelung?','Mitteln','Ja','Nein','Ja');   % berarbeiten
                switch ans1
                    case 'Ja'
                        daten = A;
                        d = str2num(char(inputdlg('Wieviele Werte sollen gemittelt werden?','Mitteln')));
                    case 'Nein'
                        condition_anzahl = 0;
                end
            else
                condition_anzahl = 0;
            end            
        end
        dlmwrite(['gemittelt_ueber' char(sprintf('%02u',d_ges)) '_Spalte'...
                num2str(spalte) '_Datei' char(sprintf('%04u',count)) '.txt'],A, 'delimiter', '\t');
            
        ans2 = questdlg('weitere Spalte mitteln?','Mitteln','Ja','Nein','Nein');
        switch ans2
            case 'Ja'
                spalte = str2num(char(inputdlg('Welche Spalte soll nun gemittelt werden?','Mitteln')));
                ans3 = questdlg('Anzahl zu mittelnder Werte von letzter Spalte bernehmen?','Mitteln','Ja','Nein','Ja');
                if strcmp(ans3,'Ja')
                    d = d_ges;
                    take_d = 1;
                else
                    take_d = 0;
                    d = str2num(char(inputdlg('Wieviele Werte sollen gemittelt werden?','Mitteln')));
                end
            case 'Nein'
                condition_spalte = 0;
        end
    end
    msgbox('Mittelung erfolgreich abgeschlossen','Mitteln')

function menu_bearbeiten_alleMitteln_Callback(hObject, eventdata, handles)
% This function extends 'menu_bearbeiten_alleMitteln_Callback' and 
% calculates the mean of d datapoints of all files (amount set with 'Anzahl Dateien' and
% saves results in new files into the results folder
    d = str2num(char(inputdlg('Wieviele Werte sollen gemittelt werden?','Mitteln')));
    filein = get(handles.EDIT_open_oeffnen,'String');
    fileout = get(handles.EDIT_open_ergebnisse,'String');
    zeilen = str2num(get(handles.EDIT_zeilen,'String'));
    anz = str2num(get(handles.EDIT_anzahl,'String'));
    [spalten,not_neccesarry] = size(get(handles.PUM_spalte,'String'));
    D = dir(filein);
    % waitbar
    hw = waitbar(0,'Berechne..','Name','alle Mitteln');
    wait_max = anz*spalten;
    for n = 1:anz
        cd (filein)
        F = getfield(D,{2+n,1},'name');
        data=importdata(F); 
        if isfield(data,'data')
            data = data.data;
        end
        cd(fileout)
        newdata = ones(zeilen/d,spalten);
        for spalte = 1:spalten
            daten=data(:,spalte);
            l=length(daten);
            if (spalte == 1) && (l ~= zeilen)
                newdata = ones(l/d,spalten);
            end
            abschnitte=l/d;
            laenge=d*floor(abschnitte);
            datenneu=daten(1:laenge,1);
            B=reshape(datenneu,d,floor(abschnitte));
            B=B';
            A=mean(B,2);
            newdata(:,spalte) = A;
            waitbar((n*spalte)/wait_max)
        end
        [parentFolder, name, ext] = fileparts(F);
        dlmwrite([name '_meanOver' char(sprintf('%02u',d)) '.txt'],newdata, 'delimiter', '\t');
    end
    %-adapt values to the meaned data
    set(handles.EDIT_fs,'String',num2str(str2num(get(handles.EDIT_fs,'String'))/d));
    set(handles.EDIT_open_oeffnen,'String',fileout);
    cm_axes_anzeigen_Callback(handles.PB_open_oeffnen, eventdata, handles)
    delete(hw);

function menu_bearbeiten_data_Callback(hObject, eventdata, handles)
    % prepare data for mean (replace ',' by '.')
    filein = get(handles.EDIT_open_oeffnen,'String');
    fileout = get(handles.EDIT_open_ergebnisse,'String');
    anz = str2num(get(handles.EDIT_anzahl,'String'));
    D = dir(filein);
    % replace ',' by '.'
    for n = 1:anz
        cd (filein)
        File = getfield(D,{2+n,1},'name');        
        % adapted from comma2point by Schrank:
        Name = textscan(File,'%s%s','delimiter','.');
        NewFile=strcat(fileout, filesep, Name{1}, '_Modified.',Name{2});
        copyfile(File, NewFile{1});
        file    = memmapfile(NewFile{1},'Writable',true);
        comma   = uint8(',');
        point   = uint8('.');
        file.Data(( file.Data==comma)' ) = point;
    end
    
%     % get information from the header, if there is one and remove it
%     D = dir(fileout);
%     %for n = 1:anz
%         cd(fileout)
%         F = getfield(D,{2+n,1},'name');
%         data=importdata(F); 
%         if isstruct(data)
%             dlmwrite(F,data.data, 'delimiter', '\t');            
%             head = str2num(char(data.textdata{1}));
%             % set data from head to GUI
%             set(handles.EDIT_fs,'String',num2str(head(1)/head(2)));
%         end
%     %end
%     
    set(handles.EDIT_open_oeffnen,'String',fileout);
    cm_axes_anzeigen_Callback(handles.PB_open_oeffnen, eventdata, handles)
   
        
% View --------------------------------------------------------------------
function menu_anzeige_figure_Callback(hObject, eventdata, handles)
% This function displays the data plot in a new figure to use all matlab
% stuff (zoom, mark, ...)
    cm_axes_anzeigen_Callback(hObject, eventdata, handles)

    
% Options -----------------------------------------------------------------   
function menu_optionen_pause_Callback(hObject, eventdata, handles)
    switch get(handles.menu_optionen_pause,'Checked')
        case 'on'
            set(handles.menu_optionen_pause,'Checked','off')
        case 'off'
            set(handles.menu_optionen_pause,'Checked','on')
    end
    
    
% Help --------------------------------------------------------------------
function menu_hilfe_ueber_Callback(hObject, eventdata, handles)
    text = sprintf('fft fit\nmain_window.m\n\nVersion 0.2          10.04.2012\n');
    msgbox(text,'About...');
 
    
    
    
    
    
%% Unused Callbacks & CreateFcns
function menu_sprache_Callback(hObject, eventdata, handles)

function menu_anzeige_Callback(hObject, eventdata, handles)
    
function EDIT_open_oeffnen_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 PB_anzahl_plus_CreateFcn(hObject, eventdata, handles)

function EDIT_open_ergebnisse_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 PUM_spalte_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 EDIT_anzahl_Callback(hObject, eventdata, handles)


function EDIT_anzahl_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 EDIT_fs_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 EDIT_af_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 EDIT_gf_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 menu_hilfe_Callback(hObject, eventdata, handles)

function EDIT_zeilen_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 EDIT_cutoff_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 SLID_sin_x_CreateFcn(hObject, eventdata, handles)

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


function SLID_sin_x2_CreateFcn(hObject, eventdata, handles)

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


function figure1_CreateFcn(hObject, eventdata, handles)

function PUM_fit_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 axes_peakhoehe_pi_Callback(hObject, eventdata, handles)


function axes_peakhoehe_pp_Callback(hObject, eventdata, handles)


function axes_peakhoehe_pw_Callback(hObject, eventdata, handles)


function axes_peakhoehe_pn_Callback(hObject, eventdata, handles)


function axes_xfit_Callback(hObject, eventdata, handles)


function EDIT_ahh_Callback(hObject, eventdata, handles)


function EDIT_ahh_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 menu_bearbeiten_Callback(hObject, eventdata, handles)


% function SLID_sin_x_ButtonDownFcn(hObject, eventdata, handles)

function PUM_peak_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 PUM_rauschen_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function CB_subplot_Callback(hObject, eventdata, handles)

function menu_datei_Callback(hObject, eventdata, handles)

function EDIT_anzGF_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 SLIDER_pause_CreateFcn(hObject, eventdata, handles)

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end

function EDIT_pause_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 menu_optionen_Callback(hObject, eventdata, handles)

Contact us