function varargout = comparing2structures(varargin)
%COMPARING2STRUCTURES M-file for comparing2structures.fig
%      COMPARING2STRUCTURES, by itself, creates a new COMPARING2STRUCTURES or raises the existing
%      singleton*.
%
%      H = COMPARING2STRUCTURES returns the handle to a new COMPARING2STRUCTURES or the handle to
%      the existing singleton*.
%
%      COMPARING2STRUCTURES('Property','Value',...) creates a new COMPARING2STRUCTURES using the
%      given property value pairs. Unrecognized properties are passed via
%      varargin to comparing2structures_OpeningFcn.  This calling syntax produces a
%      warning when there is an existing singleton*.
%
%      COMPARING2STRUCTURES('CALLBACK') and COMPARING2STRUCTURES('CALLBACK',hObject,...) call the
%      local function named CALLBACK in COMPARING2STRUCTURES.M with the given input
%      arguments.
%
%      *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 comparing2structures

% Last Modified by GUIDE v2.5 01-Feb-2005 14:23:56

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @comparing2structures_OpeningFcn, ...
                   'gui_OutputFcn',  @comparing2structures_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 comparing2structures is made visible.
function comparing2structures_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   unrecognized PropertyName/PropertyValue pairs from the
%            command line (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);

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


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

%---------- Above is good! ----------------------------------------------
%------------------------------------------------------------------------


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

d1st1= str2double(get(handles.D1St1percent, 'String'));
d2st1= str2double(get(handles.D2St1percent, 'String'));
d1st2= str2double(get(handles.D1St2percent, 'String'));
d2st2= str2double(get(handles.D2St2percent, 'String'));

% Create first plot --------------------------------------------------
axes(handles.Structure_1)
x=0:.01:40;
y= -3*x + 100;
y2= -4*x +100;
% first line
a=(d1st1-100)/(-3);
b=(d1st1-100)/(-4);
if a <= b
    y3=y;
else
    a=b;
    y3=y2;
end
%second line
c=(d2st1-100)/(-3);
d=(d2st1-100)/(-4);
if c <= d
    y4=y;
else
    c=d;
    y4=y2;
end
plot(x,y, x,y2, a,y3, c,y4)
axis([ 0 40 0 100])
xlabel= ('Dose (Gy)');
ylabel=('Percent');
title= ('Structure 1');
set(handles.Structure_1, 'XMinorTick', 'on')
grid on

% Create Second grid ------------------------------------------------
axes(handles.Structure_2);
y= -2*x + 100;
y2= -6*x + 100;
%first line
a=(d1st2-100)/(-2);
b=(d1st2-100)/(-6);
if a <= b
    y3=y;
else
    a=b;
    y3=y2;
end
%second line
c=(d2st2-100)/(-2);
d=(d2st2-100)/(-6);
if c <= d
    y4=y;
else
    c=d;
    y4=y2;
end
plot(x,y, x,y2, a,y3, c,y4)
axis([ 0 40 0 100])
xlabel=('Dose (Gy)');
ylabel=('Percent');
title=('Structure 2');
set(handles.Structure_2, 'XMinorTick', 'on')
grid on

