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

% Last Modified by GUIDE v2.5 23-Nov-2015 09:52:58

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

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


clc


% Einlesen der Daten
load('export_1_5MVA_Teil2_18_02_16.mat');
U1 = Recorder1.Channels.Segments.Data.Samples(1:20000).*10^-3;
U2 = Recorder2.Channels.Segments.Data.Samples(1:20000).*10^-3;
U3 = Recorder3.Channels.Segments.Data.Samples(1:20000).*10^-3;
I1 = Recorder5.Channels.Segments.Data.Samples(1:20000);
I1 = -I1;
I2 = Recorder6.Channels.Segments.Data.Samples(1:20000);
I3 = Recorder7.Channels.Segments.Data.Samples(1:20000);
dXstep = Recorder1.Channels.Segments.Data.dXstep;

N = length(U1);
t = N*dXstep;
Fs = N/t;


N2 = ceil (N/2);
x_bins = (0:N-1);
ts = x_bins*dXstep;
x_Hz = (0:N2-1)*Fs/N; 

handles.U1 = U1;
handles.U2 = U2;
handles.U3 = U3;
handles.I1 = I1;
handles.I2 = I2;
handles.I3 = I3;
handles.N = N;
handles.N2 = N2;
handles.x_bins = x_bins;
handles.ts = ts;
handles.x_Hz = x_Hz;

% Graphische Darstellung der Spannung L1 (Plot 1)
plot(ts,U1,'b','Parent',handles.axesU1); 
title ('Spannung L1','Parent',handles.axesU1),ylabel ('Spannung / kV','Parent',handles.axesU1);
grid on;

% Graphische Darstellung der Spannung L2
plot(ts,U2,'g','Parent',handles.axesU2);
title ('Spannung L2','Parent',handles.axesU2),ylabel ('Spannung / kV','Parent',handles.axesU2);
grid on;

% Graphische Darstellung der Spannung L3
plot(ts,U3,'r','Parent',handles.axesU3);
title ('Spannung L3','Parent',handles.axesU3),ylabel ('Spannung / kV','Parent',handles.axesU3);
grid on;

% Graphische Darstellung der Spannungen aller Leiter
hold on;
plot (ts,U1,'b','Parent',handles.axesU)
plot (ts,U2,'g','Parent',handles.axesU)
plot (ts,U3,'r','Parent',handles.axesU)
legend ('U1','U2','U3'),ylabel('Spannung / kV', 'Parent',handles.axesI), title('Spannungen L1, L2, L3', 'Parent',handles.axesI )
grid on;

% Graphische Darstellung der Stromes L1
plot (ts,I1,'b','Parent',handles.axesI1);
title ('Strom L1','Parent',handles.axesI1),ylabel ('Storm / A','Parent',handles.axesI1);
grid on;

% Graphische Darstellung der Stromes L2
plot (ts,I2,'g','Parent',handles.axesI2);
title ('Strom L1','Parent',handles.axesI2), ylabel ('Storm / A','Parent',handles.axesI2);
grid on;

% Graphische Darstellung der Stromes L3
plot (ts,I3,'r','Parent',handles.axesI3);
title ('Strom L3','Parent',handles.axesI3), ylabel ('Storm / A','Parent',handles.axesI3);
grid on;

% Graphische Darstellung der Ströme aller Leiter
hold on;
plot (ts,I1,'b','Parent',handles.axesI)
plot (ts,I2,'g','Parent',handles.axesI)
plot (ts,I3,'r','Parent',handles.axesI)
legend ('I1','I2','I3'),xlabel ('Zeit / s','Parent',handles.axesI),ylabel('Strom / A', 'Parent',handles.axesI), title('Ströme L1, L2, L3', 'Parent',handles.axesI )
grid on;

% Update handles structure
guidata(hObject, handles);

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


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