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

% Last Modified by GUIDE v2.5 11-Nov-2011 20:03:47

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

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

% Update handles structure
guidata(hObject, handles);

%Edit-Elemente auf Sliderwert setzen
    set(handles.editalpha,'String',num2str(get(handles.alpha,'Value')));
    set(handles.editpa,'String',num2str(get(handles.pa,'Value')));
    set(handles.editfuell,'String',num2str(get(handles.fuell,'Value')));


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


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



function editalpha_Callback(hObject, eventdata, handles)
val = str2double(get(handles.editalpha,'String'));
% Determine whether val is a number between 0 and 90
if isnumeric(val) & length(val)==1 & val >= get(handles.alpha,'Min') & val <= get(handles.alpha,'Max')
    alpha=get(handles.alpha,'Value');
    alpha=alpha*pi/180;
    set(handles.alpha,'Value',val);
end


% hObject    handle to editalpha (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,'String') returns contents of editalpha as text
%        str2double(get(hObject,'String')) returns contents of editalpha as a double


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

% 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


% --- Executes on slider movement.
function alpha_Callback(hObject, eventdata, handles)
set(handles.editalpha,'String',num2str(get(handles.alpha,'Value')));
alpha=get(handles.alpha,'Value');
get(handles.alpha)
alpha=alpha*pi/180;
% hObject    handle to alpha (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


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



function editpa_Callback(hObject, eventdata, handles)
val = str2double(get(handles.editpa,'String'));
% Determine whether val is a number between 0 and 8
if isnumeric(val) & length(val)==1 & val >= get(handles.pa,'Min') & val <= get(handles.pa,'Max')
    set(handles.pa,'Value',val);
end

% hObject    handle to editpa (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,'String') returns contents of editpa as text
%        str2double(get(hObject,'String')) returns contents of editpa as a double


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

% 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


% --- Executes on slider movement.
function pa_Callback(hObject, eventdata, handles)
set(handles.editpa,'String',num2str(get(handles.pa,'Value')));
alpha=get(handles.pa,'Value');
% hObject    handle to pa (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


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



function editfuell_Callback(hObject, eventdata, handles)
val = str2double(get(handles.editfuell,'String'));
% Determine whether val is a number between 0 and 1,5
if isnumeric(val) & length(val)==1 & val >= get(handles.fuell,'Min') & val <= get(handles.fuell,'Max')
    set(handles.fuell,'Value',val);
end
% hObject    handle to editfuell (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,'String') returns contents of editfuell as text
%        str2double(get(hObject,'String')) returns contents of editfuell as a double


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

% 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


% --- Executes on slider movement.
function fuell_Callback(hObject, eventdata, handles)
set(handles.editfuell,'String',num2str(get(handles.fuell,'Value')));
alpha=get(handles.fuell,'Value');
% hObject    handle to fuell (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


% --- Executes during object creation, after setting all properties.
function fuell_CreateFcn(hObject, eventdata, handles)
% hObject    handle to fuell (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 button press in start.
function start_Callback(hObject, eventdata, handles)
alpha=get(handles.alpha,'Value');
alpha=alpha*pi/180;
assignin('base','alpha',alpha);

pa=get(handles.pa,'Value')*10^5;
assignin('base','pa',pa);

x=get(handles.fuell,'Value');
assignin('base','x',x);

%Start der einzelnen Phasen

sim('Phase1_Treibstoff_Wasser')
sim('Phase2_Treibstoff_Luft')
sim('Phase3_FreiFlug')

%plot für Raketenflugbahn

x1=rakete_p1(:,1);
x2=rakete_p2(:,1);
x3=rakete_p3(:,1);
y1=rakete_p1(:,3);
y2=rakete_p2(:,3);
y3=rakete_p3(:,3);

x=[x1
 x2
 x3];
y=[y1
 y2
 y3];

axes(handles.flugbahn)
plot(x,y)

%plot für Druckabfall

p1=druck(:,1);
    p2=druck2(:,1);
    
  p=[p1
      p2];
  
  axes(handles.druck1)
    plot(p);          


% hObject    handle to start (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
