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

% Last Modified by GUIDE v2.5 25-Apr-2016 11:49:01

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

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

handles.fsample = 1500; %[Hz]%Anzahl der Singal inpuls 
% Update handles structure
guidata(hObject, handles);

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


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

%Great funktion von 1 bis 10 
%Aufruf der Diagramme von 1 bis 10 

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

% Hint: place code in OpeningFcn to populate axes1

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

% Hint: place code in OpeningFcn to populate axes2

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

% Hint: place code in OpeningFcn to populate axes3

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

% Hint: place code in OpeningFcn to populate axes4

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

% Hint: place code in OpeningFcn to populate axes5

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

% Hint: place code in OpeningFcn to populate axes6

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

% Hint: place code in OpeningFcn to populate axes7

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

% Hint: place code in OpeningFcn to populate axes8

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

% Hint: place code in OpeningFcn to populate axes9

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

% Hint: place code in OpeningFcn to populate axes10

%Pushbutton Callback Funktion für alle Diagramme von 1 bis 10 
%durch Drück der EMG-Konpf werden alle Signale aufgerufen

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

% --- Executes on slider movement.#

%................. .........EMG SIGNAL.......................

%bei erneuten Drück auf dem Konpf der EMG Singnal werden alle Signale gelöscht
cla(handles.axes1);
cla(handles.axes2);
cla(handles.axes3);
cla(handles.axes4);
cla(handles.axes5);
cla(handles.axes6);
cla(handles.axes7);
cla(handles.axes8);
cla(handles.axes9);
cla(handles.axes10);

set(handles.checkbox1,'Value',1);  %dadurch werden Checkbox 1,2 und 3 bei jeder Drück auf dem Konpf der EMG Signal auf Eines aufgesetzt.
set(handles.checkbox2,'Value',1);  
set(handles.checkbox3,'Value',1);
set(handles.checkbox5,'Value',0);  %dadurch werden Checkbox 5 und 6 bei jeder Drück auf dem Konpf der EMG Signal auf Null aufgesetzt.
set(handles.checkbox6,'Value',0);

%Diagramm aufrufen



%Date Einlesn für alle Signale von 1-10 

[EMGfilename EMGpathname] = uigetfile('*.mat','Select EMG Data File','P:\OttoBock_Dyneva\Daten_EMG\RPE\Bewegungsgesunde Probanden\AlSufyaniHesham');
pathToFileEMG = fullfile(EMGpathname, EMGfilename);

% Laden des signal
[EMG_RawSignal ] = importdata([EMGpathname EMGfilename]);  % EMG Ruhsignal wird für alle Signalen aufgerufen
size_vec = size(EMG_RawSignal.Data{1,1});                  % size_vektor ist von 1 bis 10 Date gleich ,deswegen wird nur das erste size_vec vom ersten Signal für alle Singalen benutzt.
time_vector = 0:1/handles.fsample:((size_vec(1)-1)/handles.fsample); %time_vector ist für alle Signal gleich .

% zuweisen der Musklenamen für alle Signalen für die Diagrammen von 1-6
handles.LT_Erector_spinae_longissimus = EMG_RawSignal.Data{1,1};            %LS Rückenstrecker longissimus
handles.LT_Erector_spinae_iliocostalis = EMG_RawSignal.Data{1,2};           %LS Rückenstrecker iliocostalis 
handles.LT_Obliquus_externus = EMG_RawSignal.Data{1,3};                     %LS Oblique Muskel
handles.RT_Erector_spinae_longissimus = EMG_RawSignal.Data{1,4};            %RS Rückenstrecker longissimus
handles.RT_Erector_spinae_iliocostalis = EMG_RawSignal.Data{1,5};           %RS Rückenstrecker iliocostalis 
handles.RT_Obliquus_externus = EMG_RawSignal.Data{1,6};                     %RS Oblique Muskel


%Berechnung der gleichgerichteten der Signalen für die Diagrammen von 1-6
handles.LT_Erector_spinae_longissimus_gleichgerichtet = abs(EMG_RawSignal.Data{1,1});
handles.LT_Erector_spinae_iliocostalis_gleichgerichtet = abs(EMG_RawSignal.Data{1,2});
handles.LT_Obliquus_externus_gleichgerichtet = abs(EMG_RawSignal.Data{1,3});
handles.RT_Erector_spinae_longissimus_gleichgerichtet = abs(EMG_RawSignal.Data{1,4});
handles.RT_Erector_spinae_iliocostalis_gleichgerichtet = abs(EMG_RawSignal.Data{1,5});
handles.RT_Obliquus_externus_gleichgerichtet = abs(EMG_RawSignal.Data{1,6});


%Berechnung der glättung der Signalen für die Diagrammen von 1-6
handles.fsample = 1500;                                                    %[Hz]%Anzahl der Singal inpuls
Filterlange=(handles.fsample*80*10^-3)-1;                                  %Berchnung der Filterlange

%glättenden Signalen 
signal_gestoert= handles.LT_Erector_spinae_longissimus_gleichgerichtet;
handles.LT_Erector_spinae_longissimus_geglaetet= smooth(signal_gestoert,Filterlange);
signal_gestoert= handles.LT_Erector_spinae_iliocostalis_gleichgerichtet;
handles.LT_Erector_spinae_iliocostalis_geglaetet= smooth(signal_gestoert,Filterlange);
signal_gestoert= handles.LT_Obliquus_externus_gleichgerichtet;
handles.LT_Obliquus_externus_geglaetet= smooth(signal_gestoert,Filterlange);
signal_gestoert= handles.RT_Erector_spinae_longissimus_gleichgerichtet;
handles.RT_Erector_spinae_longissimuss_geglaetet= smooth(signal_gestoert,Filterlange);
signal_gestoert= handles.RT_Erector_spinae_iliocostalis_gleichgerichtet;
handles.RT_Erector_spinae_iliocostalis_geglaetet= smooth(signal_gestoert,Filterlange);
signal_gestoert= handles.RT_Obliquus_externus_gleichgerichtet;
handles.RT_Obliquus_externus_geglaetet= smooth(signal_gestoert,Filterlange);


handles.size_vec = size(EMG_RawSignal.Data{1,1});
handles.time_vector=time_vector;                                           %Durch handles Funktion werden die Funktionen immer gespeichert

 
% Update handles structure
guidata(hObject, handles);                                                 %Update-Griffe Struktur

%Definition des Signales der Muskel für die Diagramme von 1 bis 6 
handles.yplotvector_1 = handles.LT_Erector_spinae_longissimus;        
handles.yplotvector_2 = handles.LT_Erector_spinae_iliocostalis;
handles.yplotvector_3 =handles.LT_Obliquus_externus;
handles.yplotvector_4 =handles.RT_Erector_spinae_longissimus;
handles.yplotvector_5 =handles.RT_Erector_spinae_iliocostalis;
handles.yplotvector_6 =handles.RT_Obliquus_externus;

% Ploten der Signalen von für die Diagramme von 1 bis 6 
axes(handles.axes1);   %durch handles.axes wählt man ,mit welchem Diagramm man arbeiten kann
plot(time_vector,handles.LT_Erector_spinae_longissimus,'DisplayName','EMG_RawSignal.Data{1,1}(1:16650,1)','YDataSource','EMG_RawSignal.Data{1,1}(1:16650,1)');figure(gcf)
grid on 
axes(handles.axes2);
grid on 
plot(time_vector,handles.LT_Erector_spinae_iliocostalis,'DisplayName','EMG_RawSignal.Data{1,2}(1:16650,1)','YDataSource','EMG_RawSignal.Data{1,2}(1:16650,1)');figure(gcf)
grid on 
axes(handles.axes3);
plot(time_vector,handles.LT_Obliquus_externus,'DisplayName','EMG_RawSignal.Data{1,3}(1:16650,1)','YDataSource','EMG_RawSignal.Data{1,3}(1:16650,1)');figure(gcf)
grid on 
axes(handles.axes4);
    plot(time_vector,handles.RT_Erector_spinae_longissimus,'DisplayName','EMG_RawSignal.Data{1,4}(1:16650,1)','YDataSource','EMG_RawSignal.Data{1,4}(1:16650,1)');figure(gcf)
grid on 
axes(handles.axes5);
plot(time_vector,handles.RT_Erector_spinae_iliocostalis,'DisplayName','EMG_RawSignal.Data{1,5}(1:16650,1)','YDataSource','EMG_RawSignal.Data{1,5}(1:16650,1)');figure(gcf)
grid on
axes(handles.axes6);
plot(time_vector,handles.RT_Obliquus_externus,'DisplayName','EMG_RawSignal.Data{1,6}(1:16650,1)','YDataSource','EMG_RawSignal.Data{1,6}(1:16650,1)');figure(gcf)
grid on 
hold on 
% Neue Plotgrenzen für x Achse
xmitte=(handles.time_vector(1)+handles.time_vector(end))/2;             % Berechne mitte Zeit-Vektor. X-mitte wird  mit Anfang der X-Achse und end der X-Achse durch 2  gerechnet
xhalbe=(handles.time_vector(end)/2);                                    %Berechnung halb Fensterbreite (x-Achse)


 
%Lesen der Neue Ploten Grenzen für X-Achse
set(handles.axes1,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);        %xlim Grenzen,da wird auf die X_Achse die anfang und Ende des Signales mit -,+0.5 angezeigt.
set(handles.axes2,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);
set(handles.axes3,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);
set(handles.axes4,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);
set(handles.axes5,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);
set(handles.axes6,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);


handles.xmittelpos = xmitte;


%Fensterbreite auf die X-Achse
handles.xfensterbreite = xhalbe;   


% Neue Plotgrenzen für y Achse 
ymitte=0;                                   %setze mitte der y-Achse auf Null (Signal ist immer mittelwertfrei)
yhalbe_1=max(handles.yplotvector_1);                                   % Maximum des Signales
yhalbe_2=min(handles.yplotvector_1);                                    %Minimum des Signales
if abs(yhalbe_1)>abs(yhalbe_2)
    yhalbe=abs(yhalbe_1);
else
    yhalbe=abs(yhalbe_2);
end                                                         %der betrag (Abs) ist vorhanden ,weil wir negative und positive werte haben
set(handles.axes1,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);  %ylim Grenze mit plus minus 20 auf y achse .
handles.ymittelpos_1 = ymitte;
handles.yfensterbreite_1 = yhalbe;                                   %Fensterbreite auf die Y-Achse 
handles.yfensterbreite_1_max = yhalbe;                                   %Fensterbreite auf die Y-Achse für die Position auf y achse


yhalbe_1=max(handles.yplotvector_2);
yhalbe_2=min(handles.yplotvector_2);
if abs(yhalbe_1)>abs(yhalbe_2)
    yhalbe=abs(yhalbe_1);
else
    yhalbe=abs(yhalbe_2);
end
set(handles.axes2,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_2 = ymitte;
handles.yfensterbreite_2 = yhalbe;                                   %Fensterbreite auf die Y-Achse 
handles.yfensterbreite_2_max = yhalbe;                                   %Fensterbreite auf die Y-Achse für die Position auf y achse


yhalbe_1=max(handles.yplotvector_3);
yhalbe_2=min(handles.yplotvector_3);
if abs(yhalbe_1)>abs(yhalbe_2)    
    yhalbe=abs(yhalbe_1);
else
    yhalbe=abs(yhalbe_2);
end
set(handles.axes3,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_3 = ymitte;
handles.yfensterbreite_3 = yhalbe;                                   %Fensterbreite auf die Y-Achse 
handles.yfensterbreite_3_max = yhalbe;                                   %Fensterbreite auf die Y-Achse für die Position auf y achse


yhalbe_1=max(handles.yplotvector_4);
yhalbe_2=min(handles.yplotvector_4);
if abs(yhalbe_1)>abs(yhalbe_2)    
    yhalbe=abs(yhalbe_1);
else
    yhalbe=abs(yhalbe_2);
end
set(handles.axes4,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_4 = ymitte;
handles.yfensterbreite_4 = yhalbe;                                   %Fensterbreite auf die Y-Achse 
handles.yfensterbreite_4_max = yhalbe;                                %Fensterbreite auf die Y-Achse für die Position auf y achse
                                %Fensterbreite auf die Y-Achse für die Position auf y achse


yhalbe_1=max(handles.yplotvector_5);
yhalbe_2=min(handles.yplotvector_5);
if abs(yhalbe_1)>abs(yhalbe_2)    
    yhalbe=abs(yhalbe_1);
else
    yhalbe=abs(yhalbe_2);
end

set(handles.axes5,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_5 = ymitte;
handles.yfensterbreite_5 = yhalbe;                                   %Fensterbreite auf die Y-Achse 
handles.yfensterbreite_5_max = yhalbe;   

yhalbe_1=max(handles.yplotvector_6);
yhalbe_2=min(handles.yplotvector_6);

if abs(yhalbe_1)>abs(yhalbe_2)    
    yhalbe=abs(yhalbe_1);
else
    yhalbe=abs(yhalbe_2);
end


set(handles.axes6,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_6= ymitte;
handles.yfensterbreite_6 = yhalbe;                                   %Fensterbreite auf die Y-Achse 
handles.yfensterbreite_6_max = yhalbe;                                   %Fensterbreite auf die Y-Achse für die Position auf y achse



% Update handles structure
guidata(hObject, handles);



%7.Digramm

axes(handles.axes7);
% zuweisen der Musklenamen
handles.Noraxon_Desk_Receiver.ACCEL_1_X = EMG_RawSignal.Data{1,7};
handles.Noraxon_Desk_Receiver_.ACCEL_1_Y = EMG_RawSignal.Data{1,8};
handles.Noraxon_Desk_Receiver.ACCEL_1_Z= EMG_RawSignal.Data{1,9};
%Ploten
handles.yplotvector_7_1 =handles.Noraxon_Desk_Receiver.ACCEL_1_X;
handles.yplotvector_7_2 =handles.Noraxon_Desk_Receiver_.ACCEL_1_Y;
handles.yplotvector_7_3 = handles.Noraxon_Desk_Receiver.ACCEL_1_Z;
%Ploten der X-Achse
plot(time_vector,handles.Noraxon_Desk_Receiver.ACCEL_1_X,'DisplayName','EMG_RawSignal.Data{1,7}(1:16650,1)','YDataSource','EMG_RawSignal.Data{1,7}(1:16650,1)');figure(gcf)
hold on
grid on 
%Ploten der Y-Achse
plot(time_vector,handles.Noraxon_Desk_Receiver_.ACCEL_1_Y,'g','DisplayName','EMG_RawSignal.Data{1,8}(1:16650,1)','YDataSource','EMG_RawSignal.Data{1,8}(1:16650,1)');figure(gcf)
hold on
%Ploten der Z-Achse
plot(time_vector,handles.Noraxon_Desk_Receiver.ACCEL_1_Z,'r','DisplayName','EMG_RawSignal.Data{1,9}(1:16650,1)','YDataSource','EMG_RawSignal.Data{1,9}(1:16650,1)');figure(gcf)

hold off
xmitte=(handles.time_vector(1)+handles.time_vector(end))/2;
xhalbe=(handles.time_vector(end)/2);
set(handles.axes7,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);

handles.xfensterbreite = xhalbe;


%durch das Vergleich für yhalbe_max1,2 und 3 und das Vergleich für
%yhalbe_min1,2,und 3 bekommen wir die einzele Signal im Diagramm
%vergrössert
%die folgende grenze bestimmen die grenze von der drei signale x,y und z.durch das
%maximum und minimum 
%Xsignal
if (get(handles.checkbox1,'Value') == 1)
    yhalbe_max1=max(handles.yplotvector_7_1);
    yhalbe_min1 =min(handles.yplotvector_7_1);    
else
    yhalbe_max1=0;
    yhalbe_min1=0;
    
end

%y Signal
if (get(handles.checkbox2,'Value') == 1)
    yhalbe_max2=max(handles.yplotvector_7_2);
    yhalbe_min2=min(handles.yplotvector_7_2);
else
    yhalbe_max2=0;
    yhalbe_min2=0;
end
%Z Signal
if get(handles.checkbox3,'Value') == 1
    yhalbe_max3=max(handles.yplotvector_7_3);
    yhalbe_min3=min(handles.yplotvector_7_3);
else
    yhalbe_max3=0;
    yhalbe_min3=0;
    
end

%hier haben wir das Maxmium und Minmum für alle drei Signal vergleichen.indem wir am End nur eine yhalbe_min und eine yhable_max haben, Dann haben wir
%für die beide yhalbe eine neue yhalbe_neu, dadurch wird dann die
%ymitte_neu berechnet.
%
%Maximum 
hold off


%Aufruf der Definiton der Berechnung der Maximum und Minimum

[yhalbe_max,yhalbe_min]=berechnung_max_und_min(handles,yhalbe_max1,yhalbe_min1,yhalbe_max2,yhalbe_min2,yhalbe_max3,yhalbe_min3);
yhalbe_alle=((yhalbe_max-yhalbe_min)/2);
ymitte_alle=(yhalbe_min+yhalbe_max)/2;
ymitte_neu_alle= ymitte_alle+yhalbe_alle*0;

set(handles.axes7,'YLim',[ymitte_neu_alle-yhalbe_alle,ymitte_neu_alle+yhalbe_alle]);
handles.yhalbe_alle_7=yhalbe_alle;
handles.yfensterbreite_7 = yhalbe_max;
handles.yfensterbreite_7 = yhalbe_min;
handles.ymittelpos_7 = ymitte_neu_alle;

%8.Digramm
axes(handles.axes8);

%Ploten
handles.yplotvector_8_1 =handles.Noraxon_Desk_Receiver.ACCEL_1_X;
handles.yplotvector_8_2 =handles.Noraxon_Desk_Receiver_.ACCEL_1_Y;
handles.yplotvector_8_3 = handles.Noraxon_Desk_Receiver.ACCEL_1_Z;


%Ploten der X-Achse
plot(time_vector,handles.Noraxon_Desk_Receiver.ACCEL_1_X,'DisplayName','EMG_RawSignal.Data{1,7}(1:16650,1)','YDataSource','EMG_RawSignal.Data{1,7}(1:16650,1)');figure(gcf)
hold on
%Ploten der Y-Achse
plot(time_vector,handles.Noraxon_Desk_Receiver_.ACCEL_1_Y,'g','DisplayName','EMG_RawSignal.Data{1,8}(1:16650,1)','YDataSource','EMG_RawSignal.Data{1,8}(1:16650,1)');figure(gcf)
hold on
grid on 
%Ploten der Z-Achse
plot(time_vector,handles.Noraxon_Desk_Receiver.ACCEL_1_Z,'r','DisplayName','EMG_RawSignal.Data{1,9}(1:16650,1)','YDataSource','EMG_RawSignal.Data{1,9}(1:16650,1)');figure(gcf)
hold off
xmitte=(handles.time_vector(1)+handles.time_vector(end))/2;
xhalbe=(handles.time_vector(end)/2);
set(handles.axes8,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);

handles.xfensterbreite = xhalbe;


%durch das Vergleich für yhalbe_max1,2 und 3 und das Vergleich für
%yhalbe_min1,2,und 3 bekommen wir die einzele Signal im Diagramm
%vergrössert
%die folgende grenze bestimmen die grenze von der drei signale x,y und z.durch das
%maximum und minimum 


%Xsignal
if (get(handles.checkbox1,'Value') == 1)
    yhalbe_max1=max(handles.yplotvector_8_1);
    
    yhalbe_min1 =min(handles.yplotvector_8_1);    
else
    yhalbe_max1=0;
    yhalbe_min1=0;
    
end

%y Signal
if (get(handles.checkbox2,'Value') == 1)
    yhalbe_max2=max(handles.yplotvector_8_2);
    yhalbe_min2=min(handles.yplotvector_8_2);
else
    yhalbe_max2=0;
    yhalbe_min2=0;
end
%Z Signal
if get(handles.checkbox3,'Value') == 1
    yhalbe_max3=max(handles.yplotvector_8_3);
    yhalbe_min3=min(handles.yplotvector_8_3);
else
    yhalbe_max3=0;
    yhalbe_min3=0;
    
end

%hier haben wir das Maxmium und Minmum für alle drei Signal vergleichen.indem wir am End nur eine yhalbe_min und eine yhable_max haben, Dann haben wir
%für die beide yhalbe eine neue yhalbe_neu, dadurch wird dann die
%ymitte_neu berechnet.
%
 
hold off
%Aufruf der Definiton der Berechnung der Maxmum und Minimum
[yhalbe_max,yhalbe_min]=berechnung_max_und_min(handles,yhalbe_max1,yhalbe_min1,yhalbe_max2,yhalbe_min2,yhalbe_max3,yhalbe_min3);
yhalbe_alle=((yhalbe_max-yhalbe_min)/2);
ymitte_alle=(yhalbe_min+yhalbe_max)/2;
ymitte_neu_alle= ymitte_alle+yhalbe_alle*0;
set(handles.axes8,'YLim',[ymitte_neu_alle-yhalbe_alle,ymitte_neu_alle+yhalbe_alle]);
handles.yhalbe_alle_8=yhalbe_alle;
handles.yfensterbreite_8 = yhalbe_max;
handles.yfensterbreite_8 = yhalbe_min;
handles.ymittelpos_8 = ymitte_neu_alle;
 

%9. Diagramm

axes(handles.axes9);




% zuweisen der Musklenamen
handles.Stand_Arc_Stairs_Chair = EMG_RawSignal.Data{1,10};


%Ploten
handles.yplotvector_9 =handles.Stand_Arc_Stairs_Chair;
plot(time_vector,handles.Stand_Arc_Stairs_Chair,'DisplayName','EMG_RawSignal.Data{1,10}(1:16650,1)','YDataSource','EMG_RawSignal.Data{1,10}(1:16650,1)');figure(gcf)
grid on 
xmitte=(handles.time_vector(1)+handles.time_vector(end))/2;
xhalbe=(handles.time_vector(end)/2);
set(handles.axes9,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);
handles.xfensterbreite = xhalbe;
yhalbe_1=max(handles.yplotvector_9);
yhalbe_2=min(handles.yplotvector_9);
%der betrag ist vorhanden ,weil wir negative und positive werte haben
if abs(yhalbe_1)>abs(yhalbe_2)
    yhalbe=abs(yhalbe_1);
else
    yhalbe=abs(yhalbe_2);
end
ymitte=(yhalbe_1+yhalbe_2)/2;
set(handles.axes9,'YLim',[ymitte-yhalbe,ymitte+yhalbe]);

handles.ymittelpos_9 = ymitte;
handles.yfensterbreite_9 = yhalbe;

%10. Diagramm

axes(handles.axes10);

%Laden


% zuweisen der Musklenamen
handles.Stand_Arc_Stairs_Chair = EMG_RawSignal.Data{1,10};
%Ploten

handles.yplotvector_10 =handles.Stand_Arc_Stairs_Chair;


plot(time_vector,handles.Stand_Arc_Stairs_Chair,'DisplayName','EMG_RawSignal.Data{1,10}(1:16650,1)','YDataSource','EMG_RawSignal.Data{1,10}(1:16650,1)');figure(gcf)
grid on 
xmitte=(handles.time_vector(1)+handles.time_vector(end))/2;
xhalbe=(handles.time_vector(end)/2);
set(handles.axes10,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);
handles.xfensterbreite = xhalbe;


yhalbe_1=max(handles.yplotvector_10);
yhalbe_2=min(handles.yplotvector_10);

if abs(yhalbe_1)>abs(yhalbe_2)
    yhalbe=abs(yhalbe_1);
else
    yhalbe=abs(yhalbe_2);
end






ymitte=(yhalbe_1+yhalbe_2)/2;
set(handles.axes10,'YLim',[ymitte-yhalbe,ymitte+yhalbe]);
handles.ymittelpos = ymitte;
handles.yfensterbreite_10 = yhalbe;


set(handles.pushbutton_korrektur,'Enable','on');


% Update handles structure
guidata(hObject, handles);


%Defintion der Berechnung der Maximum und Mininum 

function [yhalbe_max,yhalbe_min]=berechnung_max_und_min(handles,yhalbe_max1,yhalbe_min1,yhalbe_max2,yhalbe_min2,yhalbe_max3,yhalbe_min3)

%hier haben wir das Maxmium und Minmum für alle drei Signal vergleichen.indem wir am End nur eine yhalbe_min und eine yhable_max haben, Dann haben wir
%für die beide yhalbe eine neue yhalbe_neu, dadurch wird dann die
%ymitte_neu berechnet.

%Maximum

if (get(handles.checkbox1,'Value') == 1 && get(handles.checkbox2,'Value') == 1 && get(handles.checkbox3,'Value') == 1)
    
    if yhalbe_max1>yhalbe_max2
        if yhalbe_max1>yhalbe_max3
            yhalbe_max=yhalbe_max1;
        else
            yhalbe_max=yhalbe_max3;
        end
    else
        if yhalbe_max2>yhalbe_max3
            yhalbe_max=yhalbe_max2;
        else
            yhalbe_max=yhalbe_max3;
        end
    end
elseif (get(handles.checkbox1,'Value') == 1 && get(handles.checkbox2,'Value') == 1)
    if yhalbe_max1>yhalbe_max2
        yhalbe_max=yhalbe_max1;
    else
        yhalbe_max=yhalbe_max2;
    end
elseif (get(handles.checkbox1,'Value') == 1 && get(handles.checkbox3,'Value') == 1)
     if yhalbe_max1>yhalbe_max3
        yhalbe_max=yhalbe_max1;
    else
        yhalbe_max=yhalbe_max3;
    end
elseif  (get(handles.checkbox2,'Value') == 1 && get(handles.checkbox3,'Value') == 1)
    
    
     if yhalbe_max2>yhalbe_max3
        yhalbe_max=yhalbe_max2;
    else
        yhalbe_max=yhalbe_max3;
     end
elseif (get(handles.checkbox1,'Value') == 1)
    yhalbe_max=yhalbe_max1;
elseif (get(handles.checkbox2,'Value') == 1)
     yhalbe_max=yhalbe_max2;
elseif (get(handles.checkbox3,'Value') == 1)
    yhalbe_max=yhalbe_max3;  
    
else 
    yhalbe_max=0;    
end


%Minimum

if (get(handles.checkbox1,'Value') == 1 && get(handles.checkbox2,'Value') == 1 && get(handles.checkbox3,'Value') == 1)
    
    if yhalbe_min1<yhalbe_min2
        if yhalbe_min1<yhalbe_min3
            yhalbe_min=yhalbe_min1;
        else
            yhalbe_min=yhalbe_min3;
        end
    else
        if yhalbe_min2<yhalbe_min3
            yhalbe_min=yhalbe_min2;
        else
            yhalbe_min=yhalbe_min3;
        end
    end
elseif (get(handles.checkbox1,'Value') == 1 && get(handles.checkbox2,'Value') == 1)
    if yhalbe_min1<yhalbe_min2
        yhalbe_min=yhalbe_min1;
    else
        yhalbe_min=yhalbe_min2;
    end
elseif (get(handles.checkbox1,'Value') == 1 && get(handles.checkbox3,'Value') == 1)
     if yhalbe_min1<yhalbe_min3
        yhalbe_min=yhalbe_min1;
    else
        yhalbe_min=yhalbe_min3;
    end
elseif  (get(handles.checkbox2,'Value') == 1 && get(handles.checkbox3,'Value') == 1)
    
     if yhalbe_min2<yhalbe_min3
        yhalbe_min=yhalbe_min2;
    else
        yhalbe_min=yhalbe_min3;
     end
elseif (get(handles.checkbox1,'Value') == 1)
    yhalbe_min=yhalbe_min1;
elseif (get(handles.checkbox2,'Value') == 1)
     yhalbe_min=yhalbe_min2;
elseif (get(handles.checkbox3,'Value') == 1)
    yhalbe_min=yhalbe_min3;
    
else 
    yhalbe_min=-1;
end






%Bearbeitung der Slider für die Zoom in X-Achse
function slider1_Callback(hObject, eventdata, handles)
% hObject    handle to slider1 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

sliderpos_x = get(hObject,'Value');
xmitte=handles.xmittelpos ;
xhalbe=(handles.time_vector(end)/2)*sliderpos_x;




set(handles.axes1,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);
handles.xfensterbreite = xhalbe;
set(handles.axes2,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);
 
set(handles.axes3,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);

set(handles.axes4,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);

set(handles.axes5,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);

set(handles.axes6,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);

set(handles.axes7,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);

set(handles.axes8,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);

set(handles.axes9,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);

set(handles.axes10,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);



% Update handles structure
guidata(hObject, handles);



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

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

%Bearbeitung der Slider für die Zoom in Y-Zoom
% --- Executes on slider movement.
function slider2_Callback(hObject,eventdata, handles)
% hObject    handle to slider2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
sliderpos_y = get(hObject,'Value');


%Y Zoom Slider für 1.Diagramm 
ymitte=handles.ymittelpos_1;
yhalbe_1_1=max(handles.yplotvector_1);
yhalbe_2_1=min(handles.yplotvector_1);

if abs(yhalbe_1_1)>abs(yhalbe_2_1)
    
    yhalbe=abs(yhalbe_1_1)*sliderpos_y;
else
    yhalbe=abs(yhalbe_2_1)*sliderpos_y;
end





set(handles.axes1,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_1= ymitte;
handles.yfensterbreite_1 = yhalbe;

%Y Zomm Slider für 2.Diagramm 
ymitte=handles.ymittelpos_2;
yhalbe_1_2=max(handles.yplotvector_2);
yhalbe_2_2=min(handles.yplotvector_2);

if abs(yhalbe_1_2)>abs(yhalbe_2_2)
    
    yhalbe=abs(yhalbe_1_2)*sliderpos_y;
else
    yhalbe=abs(yhalbe_2_2)*sliderpos_y;
end

set(handles.axes2,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_2 = ymitte;
handles.yfensterbreite_2 = yhalbe;

%Y Zoom Slider für 3.Diagramm
ymitte=handles.ymittelpos_3;
yhalbe_1_3=max(handles.yplotvector_3);
yhalbe_2_3=min(handles.yplotvector_3);

if abs(yhalbe_1_3)>abs(yhalbe_2_3)
    
    yhalbe=abs(yhalbe_1_3)*sliderpos_y;
else
    yhalbe=abs(yhalbe_2_3)*sliderpos_y;
end

set(handles.axes3,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_3 = ymitte;
handles.yfensterbreite_3 = yhalbe;
%Y Zoom Slider für 4.Diagramm
ymitte=handles.ymittelpos_4;
yhalbe_1_4=max(handles.yplotvector_4);
yhalbe_2_4=min(handles.yplotvector_4);

if abs(yhalbe_1_4)>abs(yhalbe_2_4)
    
    yhalbe=abs(yhalbe_1_4)*sliderpos_y;
else
    yhalbe=abs(yhalbe_2_4)*sliderpos_y;
end

set(handles.axes4,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_4 = ymitte;
handles.yfensterbreite_4 = yhalbe;

%Y Zoom Slider für 5.Diagramm
ymitte=handles.ymittelpos_5;
yhalbe_1_5=max(handles.yplotvector_5);
yhalbe_2_5=min(handles.yplotvector_5);

if abs(yhalbe_1_5)>abs(yhalbe_2_5)
    
    yhalbe=abs(yhalbe_1_5)*sliderpos_y;
else
    yhalbe=abs(yhalbe_2_5)*sliderpos_y;
end

set(handles.axes5,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_5 = ymitte;
handles.yfensterbreite_5 = yhalbe;

%Y Zoom Slider für 6.Diagramm
ymitte=handles.ymittelpos_6;
yhalbe_1_6=max(handles.yplotvector_6);
yhalbe_2_6=min(handles.yplotvector_6);

if abs(yhalbe_1_6)>abs(yhalbe_2_6)
    
    yhalbe=abs(yhalbe_1_6)*sliderpos_y;
else
    yhalbe=abs(yhalbe_2_6)*sliderpos_y;
end

set(handles.axes6,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);

handles.yfensterbreite_6 = yhalbe;
handles.ymittelpos_6 = ymitte;


% Update handles structure
guidata(hObject, handles);



% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider


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

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

%Bearbeitung der Slider für die Position in X-Achse
% --- Executes on slider movement.
function slider3_Callback(hObject, eventdata, handles)
% hObject    handle to slider3 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
sliderpos_x = get(hObject,'Value');

xmitte=handles.time_vector(end)*sliderpos_x;
xhalbe=handles.xfensterbreite;




set(handles.axes1,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);

set(handles.axes2,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);

set(handles.axes3,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);

set(handles.axes4,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);

set(handles.axes5,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);

set(handles.axes6,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);


set(handles.axes7,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);


set(handles.axes8,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);



set(handles.axes9,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);



set(handles.axes10,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);

handles.xmittelpos = xmitte;
% Update handles structure
guidata(hObject, handles);

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

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

%Bearbeitung der Slider für die Position in Y-Achse
% --- Executes on slider movement.

function slider4_Callback(hObject, eventdata, handles)
% hObject    handle to slider4 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

sliderpos_y = get(hObject,'Value');

%Y position Slider für 1.Diagramm 
yhalbe=handles.yfensterbreite_1;
yhalbe_abstand_1=handles.yfensterbreite_1_max;
ymitte=((2*yhalbe_abstand_1)*sliderpos_y)-yhalbe_abstand_1;

set(handles.axes1,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_1 = ymitte;

%Y position Slider für 2.Diagramm 
yhalbe=handles.yfensterbreite_2;
yhalbe_abstand_2=handles.yfensterbreite_2_max;
ymitte=((2*yhalbe_abstand_2)*sliderpos_y)-yhalbe_abstand_2;


set(handles.axes2,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_2 = ymitte;
%Y position Slider für 3.Diagramm 
yhalbe=handles.yfensterbreite_3;
yhalbe_abstand_3=handles.yfensterbreite_3_max;
ymitte=((2*yhalbe_abstand_3)*sliderpos_y)-yhalbe_abstand_3;


set(handles.axes3,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_3 = ymitte;
%Y position Slider für 4.Diagramm 
yhalbe=handles.yfensterbreite_4;
yhalbe_abstand_4=handles.yfensterbreite_4_max;
ymitte=((2*yhalbe_abstand_4)*sliderpos_y)-yhalbe_abstand_4;

set(handles.axes4,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_4 = ymitte;
%Y position Slider für 5.Diagramm 
yhalbe=handles.yfensterbreite_5;
yhalbe_abstand_5=handles.yfensterbreite_5_max;
ymitte=((2*yhalbe_abstand_5)*sliderpos_y)-yhalbe_abstand_5;

set(handles.axes5,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_5 = ymitte;
%Y position Slider für 6.Diagramm 
yhalbe=handles.yfensterbreite_6;

yhalbe_abstand_6=handles.yfensterbreite_6_max;
ymitte=((2*yhalbe_abstand_6)*sliderpos_y)-yhalbe_abstand_6;

set(handles.axes6,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_6 = ymitte;


% Update handles structure
guidata(hObject, handles);




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

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




%funktion für die 7.+8. Diagramm bei Ceckbox 1+2+3.
function handles = beschleunigungPlotten(handles)

hold on
if (get(handles.checkbox1,'Value') == 1)
    yhalbe_max1=max(handles.yplotvector_7_1);
    yhalbe_min1=min(handles.yplotvector_7_1);
    plot(handles.time_vector,handles.Noraxon_Desk_Receiver.ACCEL_1_X,'b','DisplayName','EMG_RawSignal.Data{1,7}(1:16650,1)','YDataSource','EMG_RawSignal.Data{1,7}(1:16650,1)');figure(gcf)
else
    yhalbe_max1=0;
    yhalbe_min1=0;
    
end

if get(handles.checkbox2,'Value') == 1
    yhalbe_max2=max(handles.yplotvector_7_2);
    yhalbe_min2=min(handles.yplotvector_7_2);
    
    plot(handles.time_vector,handles.Noraxon_Desk_Receiver_.ACCEL_1_Y,'g','DisplayName','EMG_RawSignal.Data{1,8}(1:16650,1)','YDataSource','EMG_RawSignal.Data{1,8}(1:16650,1)');figure(gcf)
else
    yhalbe_max2=0;
    yhalbe_min2=0;
end

if get(handles.checkbox3,'Value') == 1
    yhalbe_max3=max(handles.yplotvector_7_3);
    yhalbe_min3=min(handles.yplotvector_7_3);
    plot(handles.time_vector,handles.Noraxon_Desk_Receiver.ACCEL_1_Z,'r','DisplayName','EMG_RawSignal.Data{1,9}(1:16650,1)','YDataSource','EMG_RawSignal.Data{1,9}(1:16650,1)');figure(gcf)
else
    yhalbe_max3=0;
    yhalbe_min3=0;
end
hold off



%Aufruf der Definiton der Berechnung der Maximum und Minimum
[yhalbe_max,yhalbe_min]=berechnung_max_und_min(handles,yhalbe_max1,yhalbe_min1,yhalbe_max2,yhalbe_min2,yhalbe_max3,yhalbe_min3);

yhalbe_alle=((yhalbe_max-yhalbe_min)/2);
ymitte_alle=(yhalbe_min+yhalbe_max)/2;
ymitte_neu_alle= ymitte_alle;
set(handles.axes7,'YLim',[ymitte_neu_alle-yhalbe_alle,ymitte_neu_alle+yhalbe_alle]);
set(handles.axes8,'YLim',[ymitte_neu_alle-yhalbe_alle,ymitte_neu_alle+yhalbe_alle]);
handles.yfensterbreite_7 = yhalbe_max;
handles.yfensterbreite_7 = yhalbe_min;
handles.ymittelpos_7 = ymitte_neu_alle;
handles.yhalbe_alle_7=yhalbe_alle;
set(handles.slider5,'Value',0); %dadurch wird immer der slider 5 in der mitte sein, wenn man auf checkbox1,2 oder 3 drückt.
set(handles.slider6,'Value',1)



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

%get(hObject,'Value')

%durch if Funktion bei jeder Checkbox bekommen wir durch Kliken das signal
%was wir ansehen wollen 

cla(handles.axes7);
axes(handles.axes7);
handles = beschleunigungPlotten(handles);

 %8.Diagramm Checkbox 1

cla(handles.axes8);
axes(handles.axes8);
handles = beschleunigungPlotten(handles);
 
% Update handles structure
guidata(hObject, handles);


% --- Executes on button press in checkbox2.
function checkbox2_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox2 (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 checkbox2

 %7.Diagramm Checkbox 2

cla(handles.axes7);
axes(handles.axes7);
handles = beschleunigungPlotten(handles);

 %8.Diagramm Checkbox 2

cla(handles.axes8);
axes(handles.axes8);
handles = beschleunigungPlotten(handles);
 
 % Update handles structure
guidata(hObject, handles);

 
% --- Executes on button press in checkbox3.
function checkbox3_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox3 (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 checkbox3



 %7.Diagramm Checkbox 3
cla(handles.axes7);
axes(handles.axes7);
handles = beschleunigungPlotten(handles);

 %8.Diagramm Checkbox 3

cla(handles.axes8);
axes(handles.axes8);
handles = beschleunigungPlotten(handles);
 
 % Update handles structure
guidata(hObject, handles);

 

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


% --- Executes on slider movement.
function slider5_Callback(hObject, eventdata, handles)
% hObject    handle to slider5 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
sliderpos_y = get(hObject,'Value');
axes(handles.axes7);

%1.Für jeder Signal haben wir das maxmium und manimum berechnet.dann haben
%wir alle drei signal vergleichen.
%2.Bei silder5 haben wir versucht ,dass wir immer die mittepunkt bekommen,egal
%ob wir drei, zwei oder ein Signal haben
%X Signal
if (get(handles.checkbox1,'Value') == 1)
    yhalbe_max1=max(handles.yplotvector_7_1);
    yhalbe_min1 =min(handles.yplotvector_7_1);    
else
    yhalbe_max1=0;
    yhalbe_min1=0;
end

%y Signal
if (get(handles.checkbox2,'Value') == 1)
    yhalbe_max2=max(handles.yplotvector_7_2);
    yhalbe_min2=min(handles.yplotvector_7_2);
else
    yhalbe_max2=0;
    yhalbe_min2=0;
end
%Z Signal
if get(handles.checkbox3,'Value') == 1
    yhalbe_max3=max(handles.yplotvector_7_3);
    yhalbe_min3=min(handles.yplotvector_7_3);
else
    yhalbe_max3=0;
    yhalbe_min3=0; 
end

%hier haben wir das Maxmium und Minmum für alle drei Signal vergleichen.indem wir am End nur eine yhalbe_min und eine yhable_max haben, Dann haben wir
%für die beide yhalbe eine neue yhalbe_neu, dadurch wird dann die
%ymitte_neu berechnet.
%
%Maximum 
hold off
%Aufruf der Definiton der Berechnung der Maximum und Minimum
[yhalbe_max,yhalbe_min]=berechnung_max_und_min(handles,yhalbe_max1,yhalbe_min1,yhalbe_max2,yhalbe_min2,yhalbe_max3,yhalbe_min3);


yhalbe_alle=handles.yhalbe_alle_7;
yhalbe_abstand=(yhalbe_max-yhalbe_min)/2;
ymitte_alle=(yhalbe_min+yhalbe_max)/2;
ymitte_neu_alle= ymitte_alle+yhalbe_abstand*sliderpos_y;


set(handles.axes7,'YLim',[ymitte_neu_alle-yhalbe_alle,ymitte_neu_alle+yhalbe_alle]);
handles.yfensterbreite_7 = yhalbe_max;
handles.yfensterbreite_7 = yhalbe_min;
handles.ymittelpos_7 = ymitte_neu_alle;

set(handles.axes8,'YLim',[ymitte_neu_alle-yhalbe_alle,ymitte_neu_alle+yhalbe_alle]);
handles.yfensterbreite_8 = yhalbe_max;
handles.yfensterbreite_8 = yhalbe_min;
handles.ymittelpos_8 = ymitte_neu_alle;


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

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


% --- Executes on slider movement.
function slider6_Callback(hObject, eventdata, handles)
% hObject    handle to slider6 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

sliderpos_y = get(hObject,'Value');
axes(handles.axes7);

ymitte=handles.ymittelpos_7;
%xSignal
    yhalbe_max1=max(handles.yplotvector_7_1);
    yhalbe_min1 =min(handles.yplotvector_7_1);    

%y Signal
    yhalbe_max2=max(handles.yplotvector_7_2);
    yhalbe_min2=min(handles.yplotvector_7_2);

%Z Signal
    yhalbe_max3=max(handles.yplotvector_7_3);
    yhalbe_min3=min(handles.yplotvector_7_3);



hold off
%Aufruf der Definiton der Berechnung der Maximum und Minimum
[yhalbe_max,yhalbe_min]=berechnung_max_und_min(handles,yhalbe_max1,yhalbe_min1,yhalbe_max2,yhalbe_min2,yhalbe_max3,yhalbe_min3);
yhalbe_alle=((yhalbe_max-yhalbe_min)/2)*sliderpos_y;


set(handles.axes7,'YLim',[ymitte-yhalbe_alle,ymitte+yhalbe_alle]);
handles.yhalbe_alle_7=yhalbe_alle;
handles.yfensterbreite_7 = yhalbe_max;
handles.yfensterbreite_7 = yhalbe_min;


set(handles.axes8,'YLim',[ymitte-yhalbe_alle,ymitte+yhalbe_alle]);
handles.yhalbe_alle_8=yhalbe_alle;
handles.yfensterbreite_8 = yhalbe_max;
handles.yfensterbreite_8 = yhalbe_min;

% Update handles structure
guidata(hObject, handles);


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

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

% Update handles structure
guidata(hObject, handles);

%funktion für die Ceckboxen 4+5+6 ,gleichgerichtet und glätten 

function handles = gleichgerichtetmitglaeten(handles)
%checkbox4,5und 6 für Diagramm 1
axes(handles.axes1);
cla(handles.axes1);
if (get(handles.checkbox4,'Value') == 1)
    hold on
    plot(handles.time_vector,handles.LT_Erector_spinae_longissimus,'b')
end
if (get(handles.checkbox5,'Value') == 1)
    hold on
    plot(handles.time_vector,handles.LT_Erector_spinae_longissimus_gleichgerichtet,'r')    
end
if (get(handles.checkbox6,'Value') == 1)
    hold on
    plot(handles.time_vector,handles.LT_Erector_spinae_longissimus_geglaetet,'g')
end

%checkbox4,5und 6 für Diagramm 2
axes(handles.axes2);
cla(handles.axes2);

if (get(handles.checkbox4,'Value') == 1)
    hold on
    plot(handles.time_vector,handles.LT_Erector_spinae_iliocostalis,'b')
end
if (get(handles.checkbox5,'Value') == 1)
    hold on
    plot(handles.time_vector,handles.LT_Erector_spinae_iliocostalis_gleichgerichtet,'r') 
end
if (get(handles.checkbox6,'Value') == 1)
    hold on
    plot(handles.time_vector,handles.LT_Erector_spinae_iliocostalis_geglaetet,'g')
end
hold off
%checkbox4,5und 6 für Diagramm 3
axes(handles.axes3);
cla(handles.axes3);

if (get(handles.checkbox4,'Value') == 1)
    hold on
    plot(handles.time_vector,handles.LT_Obliquus_externus,'b')
end
if (get(handles.checkbox5,'Value') == 1)
    hold on
    plot(handles.time_vector,handles.LT_Obliquus_externus_gleichgerichtet,'r')
end
if (get(handles.checkbox6,'Value') == 1)
    hold on
    plot(handles.time_vector,handles.LT_Obliquus_externus_geglaetet,'g')
end

hold off
%checkbox4,5und 6 für Diagramm 4

axes(handles.axes4);
cla(handles.axes4);

if (get(handles.checkbox4,'Value') == 1)
    hold on
    plot(handles.time_vector,handles.RT_Erector_spinae_longissimus,'b')
end
if (get(handles.checkbox5,'Value') == 1)
    hold on
    
    plot(handles.time_vector,handles.RT_Erector_spinae_longissimus_gleichgerichtet,'r')
end
if (get(handles.checkbox6,'Value') == 1)
    hold on
    plot(handles.time_vector,handles.RT_Erector_spinae_longissimuss_geglaetet,'g')
end
hold off

%checkbox4,5und 6 für Diagramm 5
axes(handles.axes5);
cla(handles.axes5);

if (get(handles.checkbox4,'Value') == 1)
    hold on
    plot(handles.time_vector,handles.RT_Erector_spinae_iliocostalis,'b')
end
if (get(handles.checkbox5,'Value') == 1)
    hold on
    plot(handles.time_vector,handles.RT_Erector_spinae_iliocostalis_gleichgerichtet,'r')    
end
if (get(handles.checkbox6,'Value') == 1)
    hold on
    plot(handles.time_vector,handles.RT_Erector_spinae_iliocostalis_geglaetet,'g')
end
hold off

%checkbox4,5und 6 für Diagramm 6

axes(handles.axes6);
cla(handles.axes6);
if (get(handles.checkbox4,'Value') == 1)
    hold on
    plot(handles.time_vector,handles.RT_Obliquus_externus,'b')
end
if (get(handles.checkbox5,'Value') == 1)
    hold on
    plot(handles.time_vector,handles.RT_Obliquus_externus_gleichgerichtet,'r')    
end
if (get(handles.checkbox6,'Value') == 1)
    hold on
    plot(handles.time_vector,handles.RT_Obliquus_externus_geglaetet,'g')
end
hold off

% --- Executes on button press in checkbox4.
function checkbox4_Callback(hObject,eventdata, handles)
% hObject    handle to checkbox4 (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 checkbox4

handles = gleichgerichtetmitglaeten(handles);

% Update handles structure
guidata(hObject, handles);

% --- Executes on button press in checkbox5.
function checkbox5_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox5 (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 checkbox5
handles = gleichgerichtetmitglaeten(handles);


% Update handles structure
guidata(hObject, handles);

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

% Update handles structure
guidata(hObject, handles);
% Hint: get(hObject,'Value') returns toggle state of checkbox6


% --- Executes on button press in pushbutton_korrektur.
function pushbutton_korrektur_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_korrektur (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
                                        %Durch handles Funktion werden die Funktionen immer gespeichert
axes(handles.axes9);
cla(handles.axes9);
handles.spannungslaevel_obereGrenze_1=240;
handles.spannungslaevel_untereGrenze_2=240;
handles.spannungslaevel_obereGrenze_2=700;
handles.spannungslaevel_untereGrenze_3=700;
handles.spannungslaevel_obereGrenze_3=1160;
handles.spannungslaevel_untereGrenze_4=1160;
handles.spannungslaevel_obereGrenze_4=1650;
handles.spannungslaevel_untereGrenze_5=2500;
handles.spannungslaevel_untereGrenze_6=1650;
handles.spannungslaevel_obereGrenze_6=2500;

handles.Stand_Arc_Stairs_Chair_1= handles.Stand_Arc_Stairs_Chair(find(handles.Stand_Arc_Stairs_Chair<handles.spannungslaevel_obereGrenze_1));
handles.time_vector_1=handles.time_vector(find(handles.Stand_Arc_Stairs_Chair<handles.spannungslaevel_obereGrenze_1));
handles.Standy_Arc_Stairs_Chair_korrigiert_1 = (handles.time_vector_1==0);


handles.Stand_Arc_Stairs_Chair_2 = handles.Stand_Arc_Stairs_Chair(find(handles.spannungslaevel_untereGrenze_2<=handles.Stand_Arc_Stairs_Chair&handles.Stand_Arc_Stairs_Chair<handles.spannungslaevel_obereGrenze_2));
handles.time_vector_2=handles.time_vector(find(handles.spannungslaevel_untereGrenze_2<=handles.Stand_Arc_Stairs_Chair&handles.Stand_Arc_Stairs_Chair<handles.spannungslaevel_obereGrenze_2));
handles.Standy_Arc_Stairs_Chair_korrigiert_2 = (handles.time_vector_2==500);

handles.Stand_Arc_Stairs_Chair_3 = handles.Stand_Arc_Stairs_Chair(find(handles.spannungslaevel_untereGrenze_3<=handles.Stand_Arc_Stairs_Chair&handles.Stand_Arc_Stairs_Chair<handles.spannungslaevel_obereGrenze_3));
handles.time_vector_3=handles.time_vector(find(handles.spannungslaevel_untereGrenze_3<=handles.Stand_Arc_Stairs_Chair&handles.Stand_Arc_Stairs_Chair<handles.spannungslaevel_obereGrenze_3));
handles.Standy_Arc_Stairs_Chair_korrigiert_3 = (handles.time_vector_3==1000);

handles.Stand_Arc_Stairs_Chair_4 = handles.Stand_Arc_Stairs_Chair(find(handles.spannungslaevel_untereGrenze_4<=handles.Stand_Arc_Stairs_Chair&handles.Stand_Arc_Stairs_Chair<handles.spannungslaevel_obereGrenze_4));
handles.time_vector_4=handles.time_vector(find(handles.spannungslaevel_untereGrenze_4<=handles.Stand_Arc_Stairs_Chair&handles.Stand_Arc_Stairs_Chair<handles.spannungslaevel_obereGrenze_4));
handles.Standy_Arc_Stairs_Chair_korrigiert_4 = (handles.time_vector_4==1500);

handles.Stand_Arc_Stairs_Chair_5 = handles.Stand_Arc_Stairs_Chair(find(handles.spannungslaevel_untereGrenze_5<=handles.Stand_Arc_Stairs_Chair));
handles.time_vector_5=handles.time_vector(find(handles.spannungslaevel_untereGrenze_5<=handles.Stand_Arc_Stairs_Chair));
handles.Standy_Arc_Stairs_Chair_korrigiert_5 = (handles.time_vector_5==2000);

handles.Stand_Arc_Stairs_Chair_6 = handles.Stand_Arc_Stairs_Chair(find(handles.spannungslaevel_untereGrenze_6<=handles.Stand_Arc_Stairs_Chair&handles.Stand_Arc_Stairs_Chair<handles.spannungslaevel_obereGrenze_6));
handles.time_vector_6=handles.time_vector(find(handles.spannungslaevel_untereGrenze_6<=handles.Stand_Arc_Stairs_Chair&handles.Stand_Arc_Stairs_Chair<handles.spannungslaevel_obereGrenze_6));
handles.Standy_Arc_Stairs_Chair_korrigiert_6 = (handles.time_vector_6==2500);

handles.Stand_Arc_Stairs_Chair_korrigiert=handles.Stand_Arc_Stairs_Chair;

handles.Stand_Arc_Stairs_Chair_korrigiert(find(handles.Stand_Arc_Stairs_Chair<=240))=0;
handles.Stand_Arc_Stairs_Chair_korrigiert(find(240<handles.Stand_Arc_Stairs_Chair&handles.Stand_Arc_Stairs_Chair<=700))=500;
handles.Stand_Arc_Stairs_Chair_korrigiert(find(700<handles.Stand_Arc_Stairs_Chair&handles.Stand_Arc_Stairs_Chair<=1160))=1000;
handles.Stand_Arc_Stairs_Chair_korrigiert(find(1160<handles.Stand_Arc_Stairs_Chair&handles.Stand_Arc_Stairs_Chair<=1650))=1500;
handles.Stand_Arc_Stairs_Chair_korrigiert(find(1650<handles.Stand_Arc_Stairs_Chair&handles.Stand_Arc_Stairs_Chair<=2500))=2000;
handles.Stand_Arc_Stairs_Chair_korrigiert(find(2500<=handles.Stand_Arc_Stairs_Chair))=3000;    


handles.analogSpannung_korrektur=handles.Stand_Arc_Stairs_Chair_korrigiert;

single = find(diff(handles.analogSpannung_korrektur(1:end-1)) ~= 0 & diff(handles.analogSpannung_korrektur(2:end) ~= 0)+1);
while single >0
    single = find(diff(handles.analogSpannung_korrektur(1:end-1)) ~= 0 & diff(handles.analogSpannung_korrektur(2:end)) ~= 0)+1;
    handles.analogSpannung_korrektur(single) = handles.analogSpannung_korrektur(single+1);
end

handles.differenzvektor= diff(handles.analogSpannung_korrektur);

%figure
%plot(analogSpannung_korrektur,'k')
% hold all
%plot(differenzvektor,'r')

%hier haben wir die Rheinfolge der Stufen und die übergang angeordnet.
handles.uebergangsvektor = zeros(length(handles.differenzvektor),1);


handles.uebergang_1=find(handles.differenzvektor== 500);
for i=1:length(handles.uebergang_1)
    
    if handles.analogSpannung_korrektur(handles.uebergang_1(i)) ==0
         handles.uebergangsvektor(handles.uebergang_1(i))=0.1;
    elseif handles.analogSpannung_korrektur(handles.uebergang_1(i)) ==1000
        handles.uebergangsvektor(handles.uebergang_1(i))=3.2;
    end
end


handles.uebergang_2=find(handles.differenzvektor== 1000);
for i=1:length(handles.uebergang_2)
    
    if handles.analogSpannung_korrektur(handles.uebergang_2(i)) ==500
        handles.uebergangsvektor(handles.uebergang_2(i))=1.2;
    else
        handles.uebergangsvektor(handles.uebergang_2(i))=5.4;
    end
end


handles.uebergang_3=find(handles.differenzvektor== 2000);
for i=1:length(handles.uebergang_3)
    
    if handles.analogSpannung_korrektur(handles.uebergang_3(i)) ==1000
        
        handles.uebergangsvektor(handles.uebergang_3(i))=3.4;
        
    else
        handles.uebergangsvektor(handles.uebergang_3(i))=0.5;
    end
end

handles.uebergang_4=find(handles.differenzvektor== -500);
for i=1:length(handles.uebergang_4)
    
    if handles.analogSpannung_korrektur(handles.uebergang_4(i)) ==1500
        
        handles.uebergangsvektor(handles.uebergang_4(i))=2.3;
        
    else
        handles.uebergangsvektor(handles.uebergang_4(i))=1.0;
    end
end


handles.uebergang_5=find(handles.differenzvektor== -1000);
for i=1:length(handles.uebergang_5)
    if handles.analogSpannung_korrektur(handles.uebergang_5(i)) ==3000
        handles.uebergangsvektor(handles.uebergang_5(i))=4.5;
    else
        handles.uebergangsvektor(handles.uebergang_5(i))=2.1;
    end
end


handles.uebergang_6=find(handles.differenzvektor== -2000);

for i=1:length(handles.uebergang_6)
    if handles.analogSpannung_korrektur(handles.uebergang_6(i)) ==2000
        handles.uebergangsvektor(handles.uebergang_6(i))=5.0;
    else
        handles.uebergangsvektor(handles.uebergang_6(i))=4.3;
    end
end
% plot(uebergangsvektor,'g')

grid on
handles.uebergangsvektor_korrigiert=find(handles.uebergangsvektor);

handles.uebergangsvektor_ohne_nullen =handles.uebergangsvektor(handles.uebergangsvektor_korrigiert);

hold on

%dadurch wird die fehler im gesamten Vektor gefunden.
v= handles.uebergangsvektor_ohne_nullen;
handles.fehlervektor =[];
for i=1:length(v)-1
     if v(i)==0.1 && v(i+1)~=1.2
             handles.fehlervektor(end+1)=i;
     end
     if v(i)==1.2 && v(i+1)~=2.3
             handles.fehlervektor(end+1)=i;
     end
     if v(i)==2.3 && v(i+1)~=3.4
        
         handles.fehlervektor(end+1)=i;
     end
     if v(i)==3.4&& v(i+1)~=4.5
             handles.fehlervektor(end+1)=i;
     end
     if v(i)==4.5 && v(i+1)~=5
             handles.fehlervektor(end+1)=i;
     end
         if v(i)==5 && v(i+1)~=0.5
             handles.fehlervektor(end+1)=i;
     end
     if v(i)==0.5 && v(i+1)~=5.4
             handles.fehlervektor(end+1)=i;
     end
     if v(i)==5.4 && v(i+1)~=4.3
             handles.fehlervektor(end+1)=i;
     end
     if v(i)==4.3 && v(i+1)~=3.2
             handles.fehlervektor(end+1)=i;
     end
     if v(i)==3.2 && v(i+1)~=2.1
             handles.fehlervektor(end+1)=i;
     end
     if v(i)==2.1 && v(i+1)~=1
             handles.fehlervektor(end+1)=i;
     end
     if v(i)==1 && v(i+1)~=0.1
             handles.fehlervektor(end+1)=i;
     end
     
end

 
% %hier wird das Vektor ohne fehler aufgerufen.
 
handles.uebergangsvektor_ohne_nullen(handles.fehlervektor)=[];
 %plot(uebergangsvektor_ohne_nullen,'r')
 
handles.fehlerindexvektor= handles.uebergangsvektor_korrigiert(handles.fehlervektor);

 for i=floor(length(handles.fehlerindexvektor))/2:-1:1
     handles.ersteLoeschIndex=handles.fehlerindexvektor(i*2-1);
     handles.zweiteLoeschIndex=handles.fehlerindexvektor(i*2);
     handles.analogSpannung_korrektur(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
     handles.LT_Erector_spinae_longissimus(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
     handles.LT_Erector_spinae_iliocostalis(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
     handles.LT_Obliquus_externus(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
     handles.RT_Erector_spinae_longissimus(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
     handles.RT_Erector_spinae_iliocostalis(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
     handles.RT_Obliquus_externus(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
     handles.Noraxon_Desk_Receiver.ACCEL_1_X(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
     handles.Noraxon_Desk_Receiver_.ACCEL_1_Y(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
     handles.Noraxon_Desk_Receiver.ACCEL_1_Z(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
     handles.LT_Erector_spinae_longissimus_gleichgerichtet(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
     handles.LT_Erector_spinae_iliocostalis_gleichgerichtet(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
     handles.LT_Obliquus_externus_gleichgerichtet(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
     handles.RT_Erector_spinae_longissimus_gleichgerichtet(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
     handles.RT_Erector_spinae_iliocostalis_gleichgerichtet(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
     handles.RT_Obliquus_externus_gleichgerichtet(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
     handles.LT_Erector_spinae_longissimus_geglaetet(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
     handles.LT_Erector_spinae_iliocostalis_geglaetet(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
     handles.LT_Obliquus_externus_geglaetet(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
     handles.RT_Erector_spinae_longissimuss_geglaetet(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
     handles.RT_Erector_spinae_iliocostalis_geglaetet(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
     handles.RT_Obliquus_externus_geglaetet(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
     handles.yplotvector_1(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
   handles.yplotvector_2(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
   handles.yplotvector_3(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
   handles.yplotvector_4(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
   handles.yplotvector_5(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
   handles.yplotvector_6(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
   handles.yplotvector_7_1(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
    handles.yplotvector_7_2(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
     handles.yplotvector_7_3(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
     handles.yplotvector_8_1(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
     handles.yplotvector_8_2(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
     handles.yplotvector_8_3(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
     handles.yplotvector_9(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
      handles.yplotvector_10(handles.ersteLoeschIndex:handles.zweiteLoeschIndex)=[];
 end
 
handles.time_vector = 0:1/handles.fsample:((length(handles.analogSpannung_korrektur)-1)/handles.fsample);
plot(handles.time_vector,handles.analogSpannung_korrektur)




 axes(handles.axes10);
 cla(handles.axes10);
handles.time_vector = 0:1/handles.fsample:((length(handles.analogSpannung_korrektur)-1)/handles.fsample);
hold on 
plot(handles.time_vector,handles.analogSpannung_korrektur)
grid on 


 
 axes(handles.axes1)
 handles.time_vector = 0:1/handles.fsample:((length(handles.LT_Erector_spinae_longissimus)-1)/handles.fsample);
 plot(handles.time_vector,handles.LT_Erector_spinae_longissimus)
 grid on 
 
xmitte=(handles.time_vector(1)+handles.time_vector(end))/2;

xhalbe=(handles.time_vector(end)/2);
handles.xmittelpos = xmitte;
set(handles.axes1,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);
 sliderpos_y = get(handles.slider4,'Value');

%Y position Slider für 1.Diagramm 
yhalbe=handles.yfensterbreite_1;
yhalbe_abstand_1=handles.yfensterbreite_1_max;
ymitte=((2*yhalbe_abstand_1)*sliderpos_y)-yhalbe_abstand_1;

set(handles.axes1,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_1 = ymitte;

 axes(handles.axes2)
 handles.time_vector= 0:1/handles.fsample:((length( handles.LT_Erector_spinae_iliocostalis)-1)/handles.fsample);
 plot(handles.time_vector, handles.LT_Erector_spinae_iliocostalis)
 grid on 
xmitte=(handles.time_vector(1)+handles.time_vector(end))/2;

xhalbe=(handles.time_vector(end)/2);
handles.xmittelpos = xmitte;
set(handles.axes2,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);
 %Y position Slider für 2.Diagramm 
yhalbe=handles.yfensterbreite_2;
yhalbe_abstand_2=handles.yfensterbreite_2_max;
ymitte=((2*yhalbe_abstand_2)*sliderpos_y)-yhalbe_abstand_2;


set(handles.axes2,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_2 = ymitte;

 axes(handles.axes3)
 handles.time_vector = 0:1/handles.fsample:((length( handles.LT_Erector_spinae_iliocostalis)-1)/handles.fsample);
 plot(handles.time_vector, handles.LT_Obliquus_externus)
 grid on 
 
xmitte=(handles.time_vector(1)+handles.time_vector(end))/2;

xhalbe=(handles.time_vector(end)/2);
handles.xmittelpos = xmitte;
set(handles.axes3,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);
 %Y position Slider für 3.Diagramm 
yhalbe=handles.yfensterbreite_3;
yhalbe_abstand_3=handles.yfensterbreite_3_max;
ymitte=((2*yhalbe_abstand_3)*sliderpos_y)-yhalbe_abstand_3;


set(handles.axes3,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_3 = ymitte;

 axes(handles.axes4)
 handles.time_vector= 0:1/handles.fsample:((length(handles.RT_Erector_spinae_longissimus)-1)/handles.fsample);
 plot(handles.time_vector, handles.RT_Erector_spinae_longissimus)
 grid on 
 
xmitte=(handles.time_vector(1)+handles.time_vector(end))/2;

xhalbe=(handles.time_vector(end)/2);
handles.xmittelpos = xmitte;
set(handles.axes4,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);
 %Y position Slider für 4.Diagramm 
yhalbe=handles.yfensterbreite_4;
yhalbe_abstand_4=handles.yfensterbreite_4_max;
ymitte=((2*yhalbe_abstand_4)*sliderpos_y)-yhalbe_abstand_4;

set(handles.axes4,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_4 = ymitte;

 axes(handles.axes5)
 handles.time_vector= 0:1/handles.fsample:((length(handles.RT_Erector_spinae_iliocostalis)-1)/handles.fsample);
 plot(handles.time_vector,handles.RT_Erector_spinae_iliocostalis)
 grid on 
 
xmitte=(handles.time_vector(1)+handles.time_vector(end))/2;

xhalbe=(handles.time_vector(end)/2);
handles.xmittelpos = xmitte;
set(handles.axes5,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);
 %Y position Slider für 5.Diagramm 
yhalbe=handles.yfensterbreite_5;
yhalbe_abstand_5=handles.yfensterbreite_5_max;
ymitte=((2*yhalbe_abstand_5)*sliderpos_y)-yhalbe_abstand_5;

set(handles.axes5,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_5 = ymitte;


 axes(handles.axes6)
 handles.time_vector= 0:1/handles.fsample:((length(handles.RT_Obliquus_externus)-1)/handles.fsample);
 plot(handles.time_vector,handles.RT_Obliquus_externus);
 grid on 
 
xmitte=(handles.time_vector(1)+handles.time_vector(end))/2;

xhalbe=(handles.time_vector(end)/2);
handles.xmittelpos = xmitte;
set(handles.axes6,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);
 

%Y position Slider für 6.Diagramm 
yhalbe=handles.yfensterbreite_6;

yhalbe_abstand_6=handles.yfensterbreite_6_max;
ymitte=((2*yhalbe_abstand_6)*sliderpos_y)-yhalbe_abstand_6;

set(handles.axes6,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_6 = ymitte;



 
 axes(handles.axes7)
 handles.time_vector= 0:1/handles.fsample:((length(handles.Noraxon_Desk_Receiver.ACCEL_1_X)-1)/handles.fsample);
 plot(handles.time_vector,handles.Noraxon_Desk_Receiver.ACCEL_1_X,'b');
 grid on 
 hold on 
 
xmitte=(handles.time_vector(1)+handles.time_vector(end))/2;

xhalbe=(handles.time_vector(end)/2);
handles.xmittelpos = xmitte;
set(handles.axes7,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);

axes(handles.axes7)
handles.time_vector= 0:1/handles.fsample:((length(handles.Noraxon_Desk_Receiver_.ACCEL_1_Y)-1)/handles.fsample);
plot(handles.time_vector,handles.Noraxon_Desk_Receiver_.ACCEL_1_Y,'g');
grid on 
xmitte=(handles.time_vector(1)+handles.time_vector(end))/2;

xhalbe=(handles.time_vector(end)/2);
handles.xmittelpos = xmitte;
set(handles.axes7,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);

 axes(handles.axes7)
 handles.time_vector= 0:1/handles.fsample:((length(handles.Noraxon_Desk_Receiver.ACCEL_1_Z)-1)/handles.fsample);
 plot(handles.time_vector,handles.Noraxon_Desk_Receiver.ACCEL_1_Z,'r');
 grid on  
xmitte=(handles.time_vector(1)+handles.time_vector(end))/2;
xhalbe=(handles.time_vector(end)/2);
handles.xmittelpos = xmitte;
set(handles.axes7,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);
  
 axes(handles.axes8)
 handles.time_vector= 0:1/handles.fsample:((length(handles.Noraxon_Desk_Receiver.ACCEL_1_X)-1)/handles.fsample);
 plot(handles.time_vector,handles.Noraxon_Desk_Receiver.ACCEL_1_X,'b');
 grid on 
 hold on 
 
xmitte=(handles.time_vector(1)+handles.time_vector(end))/2;

xhalbe=(handles.time_vector(end)/2);
handles.xmittelpos = xmitte;
set(handles.axes8,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);
 axes(handles.axes8)
 handles.time_vector= 0:1/handles.fsample:((length(handles.Noraxon_Desk_Receiver_.ACCEL_1_Y)-1)/handles.fsample);
 plot(handles.time_vector,handles.Noraxon_Desk_Receiver_.ACCEL_1_Y,'g');
 grid on 
 
xmitte=(handles.time_vector(1)+handles.time_vector(end))/2;

xhalbe=(handles.time_vector(end)/2);
handles.xmittelpos = xmitte;
set(handles.axes8,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);
 axes(handles.axes8)
 handles.time_vector= 0:1/handles.fsample:((length(handles.Noraxon_Desk_Receiver.ACCEL_1_Z)-1)/handles.fsample);
 plot(handles.time_vector,handles.Noraxon_Desk_Receiver.ACCEL_1_Z,'r');
 grid on 
 
xmitte=(handles.time_vector(1)+handles.time_vector(end))/2;

xhalbe=(handles.time_vector(end)/2);
handles.xmittelpos = xmitte;
set(handles.axes8,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);
 
set(handles.pushbutton8,'Enable','on');


guidata(hObject, handles);


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



set(handles.checkbox1,'Value',1);  %dadurch werden Checkbox 1,2 und 3 bei jeder Drück auf dem Konpf der EMG Signal auf Eines aufgesetzt.
set(handles.checkbox2,'Value',1);  
set(handles.checkbox3,'Value',1);
set(handles.checkbox5,'Value',0);  %dadurch werden Checkbox 5 und 6 bei jeder Drück auf dem Konpf der EMG Signal auf Null aufgesetzt.
set(handles.checkbox6,'Value',0);

set(handles.slider5,'Value',0); %dadurch wird immer der slider 5 in der mitte sein, wenn man auf checkbox1,2 oder 3 drückt.

set(handles.slider6,'Value',1);
set(handles.slider2,'Value',1);
set(handles.slider1,'Value',1);

set(handles.slider3,'Value',0.5); 
set(handles.slider4,'Value',0.5); 
% axes(handles.axes9);
% cla(handles.axes9);
% 
% 
% 
% handles.time_vector = 0:1/handles.fsample:((length(handles.analogSpannung_korrektur)-1)/handles.fsample);
% plot(handles.time_vector,handles.analogSpannung_korrektur)
% 
% 
% 
% axes(handles.axes10);
% cla(handles.axes10);
% handles.time_vector = 0:1/handles.fsample:((length(handles.analogSpannung_korrektur)-1)/handles.fsample);
% hold on 
% plot(handles.time_vector,handles.analogSpannung_korrektur)
% grid on 
% 
% 
%  
%  axes(handles.axes1)

  sliderpos_y_1 = get(handles.slider4,'Value');
 sliderpos_y_2 = get(handles.slider2,'Value');
 %x position Slider für 1.Diagramm
xmitte=(handles.time_vector(1)+handles.time_vector(end))/2;
xhalbe=(handles.time_vector(end)/2);
handles.xmittelpos = xmitte;
set(handles.axes1,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);


%Y position Slider für 1.Diagramm 
yhalbe=handles.yfensterbreite_1;
yhalbe_abstand_1=handles.yfensterbreite_1_max;
ymitte=((2*yhalbe_abstand_1)*sliderpos_y_1)-yhalbe_abstand_1;

set(handles.axes1,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_1 = ymitte;
 yhalbe_1_1=max(handles.yplotvector_1);
yhalbe_2_1=min(handles.yplotvector_1);

if abs(yhalbe_1_1)>abs(yhalbe_2_1)
    
    yhalbe=abs(yhalbe_1_1)*sliderpos_y_2;
else
    yhalbe=abs(yhalbe_2_1)*sliderpos_y_2;
end





set(handles.axes1,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_1= ymitte;
handles.yfensterbreite_1 = yhalbe;


 
% axes(handles.axes2)
xmitte=(handles.time_vector(1)+handles.time_vector(end))/2;

xhalbe=(handles.time_vector(end)/2);
handles.xmittelpos = xmitte;
set(handles.axes2,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);

 %Y position Slider für 2.Diagramm 
yhalbe=handles.yfensterbreite_2;
yhalbe_abstand_2=handles.yfensterbreite_2_max;
ymitte=((2*yhalbe_abstand_2)*sliderpos_y_1)-yhalbe_abstand_2;
set(handles.axes2,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_2 = ymitte;
 yhalbe_1_1=max(handles.yplotvector_2);
yhalbe_2_1=min(handles.yplotvector_2);

if abs(yhalbe_1_1)>abs(yhalbe_2_1)
    
    yhalbe=abs(yhalbe_1_1)*sliderpos_y_2;
else
    yhalbe=abs(yhalbe_2_1)*sliderpos_y_2;
end





set(handles.axes2,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_2= ymitte;
handles.yfensterbreite_2 = yhalbe;


%  axes(handles.axes3)

 
xmitte=(handles.time_vector(1)+handles.time_vector(end))/2;

xhalbe=(handles.time_vector(end)/2);
handles.xmittelpos = xmitte;
set(handles.axes3,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);
 %Y position Slider für 3.Diagramm 
yhalbe=handles.yfensterbreite_3;
yhalbe_abstand_3=handles.yfensterbreite_3_max;
ymitte=((2*yhalbe_abstand_3)*sliderpos_y_1)-yhalbe_abstand_3;


set(handles.axes3,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_3 = ymitte;
 yhalbe_1_1=max(handles.yplotvector_3);
yhalbe_2_1=min(handles.yplotvector_3);

if abs(yhalbe_1_1)>abs(yhalbe_2_1)
    
    yhalbe=abs(yhalbe_1_1)*sliderpos_y_2;
else
    yhalbe=abs(yhalbe_2_1)*sliderpos_y_2;
end





set(handles.axes3,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_3= ymitte;
handles.yfensterbreite_3 = yhalbe;


%  axes(handles.axes4)

xmitte=(handles.time_vector(1)+handles.time_vector(end))/2;

xhalbe=(handles.time_vector(end)/2);
handles.xmittelpos = xmitte;
set(handles.axes4,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);
 %Y position Slider für 4.Diagramm 
yhalbe=handles.yfensterbreite_4;
yhalbe_abstand_4=handles.yfensterbreite_4_max;
ymitte=((2*yhalbe_abstand_4)*sliderpos_y_1)-yhalbe_abstand_4;

set(handles.axes4,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_4 = ymitte;
 yhalbe_1_1=max(handles.yplotvector_4);
yhalbe_2_1=min(handles.yplotvector_4);

if abs(yhalbe_1_1)>abs(yhalbe_2_1)
    
    yhalbe=abs(yhalbe_1_1)*sliderpos_y_2;
else
    yhalbe=abs(yhalbe_2_1)*sliderpos_y_2;
end





set(handles.axes4,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_4= ymitte;
handles.yfensterbreite_4 = yhalbe;


%  axes(handles.axes5)
 
 
xmitte=(handles.time_vector(1)+handles.time_vector(end))/2;

xhalbe=(handles.time_vector(end)/2);
handles.xmittelpos = xmitte;
set(handles.axes5,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);
 %Y position Slider für 5.Diagramm 
yhalbe=handles.yfensterbreite_5;
yhalbe_abstand_5=handles.yfensterbreite_5_max;
ymitte=((2*yhalbe_abstand_5)*sliderpos_y_1)-yhalbe_abstand_5;

set(handles.axes5,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_5 = ymitte;

 yhalbe_1_1=max(handles.yplotvector_5);
yhalbe_2_1=min(handles.yplotvector_5);

if abs(yhalbe_1_1)>abs(yhalbe_2_1)
    
    yhalbe=abs(yhalbe_1_1)*sliderpos_y_2;
else
    yhalbe=abs(yhalbe_2_1)*sliderpos_y_2;
end





set(handles.axes5,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_5= ymitte;
handles.yfensterbreite_5 = yhalbe;


%  axes(handles.axes6)

xmitte=(handles.time_vector(1)+handles.time_vector(end))/2;

xhalbe=(handles.time_vector(end)/2);
handles.xmittelpos = xmitte;
set(handles.axes6,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);
 

%Y position Slider für 6.Diagramm 
yhalbe=handles.yfensterbreite_6;

yhalbe_abstand_6=handles.yfensterbreite_6_max;
ymitte=((2*yhalbe_abstand_6)*sliderpos_y_1)-yhalbe_abstand_6;

set(handles.axes6,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_6 = ymitte;
 yhalbe_1_1=max(handles.yplotvector_6);
yhalbe_2_1=min(handles.yplotvector_6);

if abs(yhalbe_1_1)>abs(yhalbe_2_1)
    
    yhalbe=abs(yhalbe_1_1)*sliderpos_y_2;
else
    yhalbe=abs(yhalbe_2_1)*sliderpos_y_2;
end





set(handles.axes6,'YLim',[ymitte-yhalbe-20,ymitte+yhalbe+20]);
handles.ymittelpos_6= ymitte;
handles.yfensterbreite_6 = yhalbe;

   sliderpos_y_5 = get(handles.slider5,'Value');
   sliderpos_y_6 = get(handles.slider6,'Value');
   
set(handles.axes7,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);

set(handles.axes8,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);

set(handles.axes9,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);

set(handles.axes10,'XLim',[xmitte-xhalbe-0.5,xmitte+xhalbe+0.5]);

axes(handles.axes7);

%1.Für jeder Signal haben wir das maxmium und manimum berechnet.dann haben
%wir alle drei signal vergleichen.
%2.Bei silder5 haben wir versucht ,dass wir immer die mittepunkt bekommen,egal
%ob wir drei, zwei oder ein Signal haben
%X Signal
if (get(handles.checkbox1,'Value') == 1)
    yhalbe_max1=max(handles.yplotvector_7_1);
    yhalbe_min1 =min(handles.yplotvector_7_1);    
else
    yhalbe_max1=0;
    yhalbe_min1=0;
end

%y Signal
if (get(handles.checkbox2,'Value') == 1)
    yhalbe_max2=max(handles.yplotvector_7_2);
    yhalbe_min2=min(handles.yplotvector_7_2);
else
    yhalbe_max2=0;
    yhalbe_min2=0;
end
%Z Signal
if get(handles.checkbox3,'Value') == 1
    yhalbe_max3=max(handles.yplotvector_7_3);
    yhalbe_min3=min(handles.yplotvector_7_3);
else
    yhalbe_max3=0;
    yhalbe_min3=0; 
end

%hier haben wir das Maxmium und Minmum für alle drei Signal vergleichen.indem wir am End nur eine yhalbe_min und eine yhable_max haben, Dann haben wir
%für die beide yhalbe eine neue yhalbe_neu, dadurch wird dann die
%ymitte_neu berechnet.
%
%Maximum 
hold off
%Aufruf der Definiton der Berechnung der Maximum und Minimum
[yhalbe_max,yhalbe_min]=berechnung_max_und_min(handles,yhalbe_max1,yhalbe_min1,yhalbe_max2,yhalbe_min2,yhalbe_max3,yhalbe_min3);


yhalbe_alle=handles.yhalbe_alle_7;
yhalbe_abstand=(yhalbe_max-yhalbe_min)/2;
ymitte_alle=(yhalbe_min+yhalbe_max)/2;
ymitte_neu_alle= ymitte_alle+yhalbe_abstand*sliderpos_y_5;


set(handles.axes7,'YLim',[ymitte_neu_alle-yhalbe_alle,ymitte_neu_alle+yhalbe_alle]);
handles.yfensterbreite_7 = yhalbe_max;
handles.yfensterbreite_7 = yhalbe_min;
handles.ymittelpos_7 = ymitte_neu_alle;

set(handles.axes8,'YLim',[ymitte_neu_alle-yhalbe_alle,ymitte_neu_alle+yhalbe_alle]);
handles.yfensterbreite_8 = yhalbe_max;
handles.yfensterbreite_8 = yhalbe_min;
handles.ymittelpos_8 = ymitte_neu_alle;

axes(handles.axes7);

ymitte=handles.ymittelpos_7;
%xSignal
    yhalbe_max1=max(handles.yplotvector_7_1);
    yhalbe_min1 =min(handles.yplotvector_7_1);    

%y Signal
    yhalbe_max2=max(handles.yplotvector_7_2);
    yhalbe_min2=min(handles.yplotvector_7_2);

%Z Signal
    yhalbe_max3=max(handles.yplotvector_7_3);
    yhalbe_min3=min(handles.yplotvector_7_3);



hold off
%Aufruf der Definiton der Berechnung der Maximum und Minimum
[yhalbe_max,yhalbe_min]=berechnung_max_und_min(handles,yhalbe_max1,yhalbe_min1,yhalbe_max2,yhalbe_min2,yhalbe_max3,yhalbe_min3);
yhalbe_alle=((yhalbe_max-yhalbe_min)/2)*sliderpos_y_6;


set(handles.axes7,'YLim',[ymitte-yhalbe_alle,ymitte+yhalbe_alle]);
handles.yhalbe_alle_7=yhalbe_alle;
handles.yfensterbreite_7 = yhalbe_max;
handles.yfensterbreite_7 = yhalbe_min;


set(handles.axes8,'YLim',[ymitte-yhalbe_alle,ymitte+yhalbe_alle]);
handles.yhalbe_alle_8=yhalbe_alle;
handles.yfensterbreite_8 = yhalbe_max;
handles.yfensterbreite_8 = yhalbe_min;

cla(handles.axes7);
axes(handles.axes7);
handles = beschleunigungPlotten(handles);

 %8.Diagramm Checkbox 1

cla(handles.axes8);
axes(handles.axes8);
handles = beschleunigungPlotten(handles);


 
guidata(hObject, handles);
