Code covered by the BSD License  

Highlights from
Rosin-Rammler Diagram plotting tool

image thumbnail

Rosin-Rammler Diagram plotting tool

by

 

25 Jun 2010 (Updated )

This tool plots the Rosin-Rammler Diagram (RRSB) and calculates various related parameters.

edit_RRD(varargin)
function varargout = edit_RRD(varargin)
%% MATLAB(R) tool for plotting Rosin-Rammler size distribution diagram
%
%                 Ivan Brezani (a) and Fridrich Zelenak
%
%                   Technical University of Kosice,
%                            BERG Faculty,
%     Institute of Montanneous Sciences and Environmental Protection
%
%                      Last updated: 2010-07-27
%
% 
% (a) ivan.brezani@tuke.sk
% 

% Copyright (c) 2010, Ivan Brezani
% All rights reserved.
%
% Redistribution and use in source and binary forms, with or without 
% modification, are permitted provided that the following conditions are 
% met:
%
%    * Redistributions of source code must retain the above copyright 
%      notice, this list of conditions and the following disclaimer.
%    * Redistributions in binary form must reproduce the above copyright 
%      notice, this list of conditions and the following disclaimer in 
%      the documentation and/or other materials provided with the distribution
%    * Neither the name of the University Paris Sud nor the names 
%      of its contributors may be used to endorse or promote products derived 
%      from this software without specific prior written permission.
%      
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
% POSSIBILITY OF SUCH DAMAGE.

% EDIT_RRD M-file for edit_RRD.fig
%      EDIT_RRD, by itself, creates a new EDIT_RRD or raises the existing
%      singleton*.
%
%      H = EDIT_RRD returns the handle to a new EDIT_RRD or the handle to
%      the existing singleton*.
%
%      EDIT_RRD('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in EDIT_RRD.M with the given input arguments.
%
%      EDIT_RRD('Property','Value',...) creates a new EDIT_RRD or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before edit_RRD_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to edit_RRD_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_rrd the above text to modify the response to help edit_RRD

% Last Modified by GUIDE v2.5 22-Sep-2010 09:43:04

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

if handles.open == 1
    set(handles.popupmenu_units, 'Value', handles.x_axis_units_e);
    set(handles.edit_Xmin, 'String', num2str(handles.xmin_e));
    set(handles.edit_Xmax, 'String', num2str(handles.xmax_e));
    set(handles.edit_Ymin, 'String', num2str(handles.ymin_e));
    set(handles.edit_Ymax, 'String', num2str(handles.ymax_e));
    set(handles.checkbox_show1, 'Value', handles.show1_e);
    set(handles.checkbox_show2, 'Value', handles.show2_e);
    set(handles.checkbox_show3, 'Value', handles.show3_e);
    set(handles.checkbox_X_auto_lim, 'Value', handles.auto_lim_e);
    set(handles.edit_points1, 'String', handles.legend_text_1_e);
    set(handles.edit_approx1, 'String', handles.legend_text_2_e);
    set(handles.edit_points2, 'String', handles.legend_text_3_e);
    set(handles.edit_approx2, 'String', handles.legend_text_4_e);
    set(handles.edit_points3, 'String', handles.legend_text_5_e);
    set(handles.edit_approx3, 'String', handles.legend_text_6_e);
    set(handles.edit_Xlabel, 'String', handles.xlabel_text_e);
    set(handles.edit_Ylabel, 'String', handles.ylabel_text_e);
    set(handles.edit_title, 'String', handles.title_text_e);
    handles.open = 0;
end

guidata(hObject, handles);

% --- Outputs from this function are returned to the command line.
function varargout = edit_RRD_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 edit_Ymin_Callback(hObject, eventdata, handles)
% hObject    handle to edit_Ymin (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 edit_Ymin as text
%        str2double(get(hObject,'String')) returns contents of edit_Ymin as a double
if isnan(str2double(get(hObject,'String'))) == 1
    uiwait(errordlg('Please enter numerical value.', 'Error', 'Modal'));
    set(hObject, 'String', num2str(handles.ymin_e));
elseif str2double(get(hObject,'String')) >= handles.ymax_e
    uiwait(errordlg('Y-axis minimum must be lower than maximum.', 'Error', 'Modal'));
    set(hObject, 'String', num2str(handles.ymin_e));
elseif str2double(get(hObject,'String')) < 0.001 || str2double(get(hObject,'String')) > 99.999
    uiwait(errordlg('Minimum on Y-axis must be a number between 0.001 and 99.999 [%].', 'Error', 'Modal'));
    set(hObject, 'String', num2str(handles.ymin_e));
else
    handles.ymin_e = str2double(get(hObject, 'String'));
end
guidata(hObject, handles);

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

mainGUIhandle = RRD;
mainGUIdata  = guidata(mainGUIhandle);

handles.x_axis_units_e = mainGUIdata.x_axis_units;
handles.xmin_e = mainGUIdata.xmin;
handles.xmax_e = mainGUIdata.xmax;
handles.ymin_e = mainGUIdata.ymin;
handles.ymax_e = mainGUIdata.ymax;
handles.show1_e = mainGUIdata.show1;
handles.show2_e = mainGUIdata.show2;
handles.show3_e = mainGUIdata.show3;
handles.auto_lim_e = mainGUIdata.auto_lim;
handles.legend_text_1_e = mainGUIdata.legend_text_1;
handles.legend_text_2_e = mainGUIdata.legend_text_2;
handles.legend_text_3_e = mainGUIdata.legend_text_3;
handles.legend_text_4_e = mainGUIdata.legend_text_4;
handles.legend_text_5_e = mainGUIdata.legend_text_5;
handles.legend_text_6_e = mainGUIdata.legend_text_6;
handles.xlabel_text_e = mainGUIdata.xlabel_text;
handles.ylabel_text_e = mainGUIdata.ylabel_text;
handles.title_text_e = mainGUIdata.title_text;

handles.open = 1;

guidata(hObject, handles);


function edit_Ymax_Callback(hObject, eventdata, handles)
% hObject    handle to edit_Ymax (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 edit_Ymax as text
%        str2double(get(hObject,'String')) returns contents of edit_Ymax as a double
if isnan(str2double(get(hObject,'String'))) == 1
    uiwait(errordlg('Please enter numerical value.', 'Error', 'Modal'));
    set(hObject, 'String', num2str(handles.ymax_e));
elseif str2double(get(hObject,'String')) <= handles.ymin_e
    uiwait(errordlg('Y-axis maximum must be higher than minimum.', 'Error', 'Modal'));
    set(hObject, 'String', num2str(handles.ymax_e));
elseif str2double(get(hObject,'String')) < 0.001 || str2double(get(hObject,'String')) > 99.999
    uiwait(errordlg('Maximum on Y-axis must be a number between 0.001 and 99.999 [%].', 'Error', 'Modal'));
    set(hObject, 'String', num2str(handles.ymax_e));
else
    handles.ymax_e = str2double(get(hObject, 'String'));
end
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function edit_Ymax_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_Ymax (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_RRD controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit_Xmin_Callback(hObject, eventdata, handles)
% hObject    handle to edit_Xmin (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 edit_Xmin as text
%        str2double(get(hObject,'String')) returns contents of edit_Xmin as a double
if isnan(str2double(get(hObject,'String'))) == 1
    uiwait(errordlg('Please enter numerical value.', 'Error', 'Modal'));
    set(hObject, 'String', num2str(handles.xmin_e));
elseif str2double(get(hObject,'String')) >= handles.xmax_e
    uiwait(errordlg('X-axis minimum must be lower than maximum.', 'Error', 'Modal'));
    set(hObject, 'String', num2str(handles.xmin_e));
else
    handles.xmin_e = str2double(get(hObject, 'String'));
end
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function edit_Xmin_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_Xmin (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_RRD controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit_Xmax_Callback(hObject, eventdata, handles)
% hObject    handle to edit_Xmax (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 edit_Xmax as text
%        str2double(get(hObject,'String')) returns contents of edit_Xmax as a double
if isnan(str2double(get(hObject,'String'))) == 1
    uiwait(errordlg('Please enter numerical value.', 'Error', 'Modal'));
    set(hObject, 'String', num2str(handles.xmax_e));
elseif str2double(get(hObject,'String')) <= handles.xmin_e
    uiwait(errordlg('X-axis maximum must be higher than minimum.', 'Error', 'Modal'));
    set(hObject, 'String', num2str(handles.xmax_e));
else
    handles.xmax_e = str2double(get(hObject, 'String'));
end
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function edit_Xmax_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_Xmax (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_RRD 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 button press in checkbox_X_auto_lim.
function checkbox_X_auto_lim_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox_X_auto_lim (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 checkbox_X_auto_lim
handles.auto_lim_e = get(hObject,'Value');
guidata(hObject, handles);


function edit_points1_Callback(hObject, eventdata, handles)
% hObject    handle to edit_points1 (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 edit_points1 as text
%        str2double(get(hObject,'String')) returns contents of edit_points1 as a double
handles.legend_text_1_e = get(hObject,'String');
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function edit_points1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_points1 (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_RRD controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit_approx1_Callback(hObject, eventdata, handles)
% hObject    handle to edit_approx1 (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 edit_approx1 as text
%        str2double(get(hObject,'String')) returns contents of edit_approx1 as a double
handles.legend_text_2_e = get(hObject,'String');
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function edit_approx1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_approx1 (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_RRD controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit_points2_Callback(hObject, eventdata, handles)
% hObject    handle to edit_points2 (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 edit_points2 as text
%        str2double(get(hObject,'String')) returns contents of edit_points2 as a double
handles.legend_text_3_e = get(hObject,'String');
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function edit_points2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_points2 (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_RRD controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit_approx2_Callback(hObject, eventdata, handles)
% hObject    handle to edit_approx2 (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 edit_approx2 as text
%        str2double(get(hObject,'String')) returns contents of edit_approx2 as a double
handles.legend_text_4_e = get(hObject,'String');
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function edit_approx2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_approx2 (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_RRD controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit_points3_Callback(hObject, eventdata, handles)
% hObject    handle to edit_points3 (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 edit_points3 as text
%        str2double(get(hObject,'String')) returns contents of edit_points3 as a double
handles.legend_text_5_e = get(hObject,'String');
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function edit_points3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_points3 (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_RRD controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit_approx3_Callback(hObject, eventdata, handles)
% hObject    handle to edit_approx3 (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 edit_approx3 as text
%        str2double(get(hObject,'String')) returns contents of edit_approx3 as a double
handles.legend_text_6_e = get(hObject,'String');
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function edit_approx3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_approx3 (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_RRD controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit_Xlabel_Callback(hObject, eventdata, handles)
% hObject    handle to edit_Xlabel (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 edit_Xlabel as text
%        str2double(get(hObject,'String')) returns contents of edit_Xlabel as a double
handles.xlabel_text_e = get(hObject,'String');
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function edit_Xlabel_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_Xlabel (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_RRD controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit_Ylabel_Callback(hObject, eventdata, handles)
% hObject    handle to edit_Ylabel (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 edit_Ylabel as text
%        str2double(get(hObject,'String')) returns contents of edit_Ylabel as a double
handles.ylabel_text_e = get(hObject,'String');
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function edit_Ylabel_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_Ylabel (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_RRD controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit_title_Callback(hObject, eventdata, handles)
% hObject    handle to edit_title (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 edit_title as text
%        str2double(get(hObject,'String')) returns contents of edit_title as a double
handles.title_text_e = get(hObject,'String');
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function edit_title_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_title (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_RRD 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 button press in pushbutton_cancel.
function pushbutton_cancel_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_cancel (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
delete(gcf);


% --- Executes on button press in pushbutton_accept.
function pushbutton_accept_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_accept (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
mainGUIhandle = RRD;
mainGUIdata  = guidata(mainGUIhandle);

mainGUIdata.xmin = handles.xmin_e;
mainGUIdata.xmax = handles.xmax_e;
mainGUIdata.ymin = handles.ymin_e;
mainGUIdata.ymax = handles.ymax_e;
mainGUIdata.show1 = handles.show1_e;
mainGUIdata.show2 = handles.show2_e;
mainGUIdata.show3 = handles.show3_e;
mainGUIdata.auto_lim = handles.auto_lim_e;
mainGUIdata.legend_text_1 = handles.legend_text_1_e;
mainGUIdata.legend_text_2 = handles.legend_text_2_e;
mainGUIdata.legend_text_3 = handles.legend_text_3_e;
mainGUIdata.legend_text_4 = handles.legend_text_4_e;
mainGUIdata.legend_text_5 = handles.legend_text_5_e;
mainGUIdata.legend_text_6 = handles.legend_text_6_e;
mainGUIdata.xlabel_text = handles.xlabel_text_e;
mainGUIdata.ylabel_text = handles.ylabel_text_e;
mainGUIdata.title_text = handles.title_text_e;
mainGUIdata.x_axis_units = handles.x_axis_units_e;

guidata(RRD, mainGUIdata);
uiwait(helpdlg('Please replot graph to apply new settings', 'Info'));
delete(edit_RRD);


% --- Executes on button press in checkbox_show1.
function checkbox_show1_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox_show1 (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 checkbox_show1
handles.show1_e = get(hObject,'Value');
guidata(hObject, handles);

% --- Executes on button press in checkbox_show2.
function checkbox_show2_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox_show2 (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 checkbox_show2
handles.show2_e = get(hObject,'Value');
guidata(hObject, handles);

% --- Executes on button press in checkbox_show3.
function checkbox_show3_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox_show3 (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 checkbox_show3
handles.show3_e = get(hObject,'Value');
guidata(hObject, handles);


% --- Executes on selection change in popupmenu_units.
function popupmenu_units_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu_units (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_units contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu_units
% Determine the selected data set.
str = get(hObject, 'String');
val = get(hObject,'Value');
% Set current data to the selected data set.
switch str{val};
case 'micron' % User selects peaks.
   handles.x_axis_units_e = 1;
case 'mm' % User selects membrane.
   handles.x_axis_units_e = 2;
case 'cm' % User selects sinc.
   handles.x_axis_units_e = 3;
case 'dm' % User selects sinc.
   handles.x_axis_units_e = 4;
case 'm' % User selects sinc.
   handles.x_axis_units_e = 5;
end
% Save the handles structure.
guidata(hObject,handles)

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

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes when user attempts to close figure_edit_RRD.
function figure_edit_RRD_CloseRequestFcn(hObject, eventdata, handles)
% hObject    handle to figure_edit_RRD (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: delete(hObject) closes the figure
delete(hObject);


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


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

Saved_options = cell(18,1);

Saved_options(1,1) = num2cell(handles.xmin_e);
Saved_options(2,1) = num2cell(handles.xmax_e);
Saved_options(3,1) = num2cell(handles.ymin_e);
Saved_options(4,1) = num2cell(handles.ymax_e);
Saved_options(5,1) = num2cell(handles.show1_e);
Saved_options(6,1) = num2cell(handles.show2_e);
Saved_options(7,1) = num2cell(handles.show3_e);
Saved_options(8,1) = num2cell(handles.auto_lim_e);
Saved_options(9,1) = {handles.legend_text_1_e};
Saved_options(10,1) = {handles.legend_text_2_e};
Saved_options(11,1) = {handles.legend_text_3_e};
Saved_options(12,1) = {handles.legend_text_4_e};
Saved_options(13,1) = {handles.legend_text_5_e};
Saved_options(14,1) = {handles.legend_text_6_e};
Saved_options(15,1) = {handles.xlabel_text_e};

if isempty(strfind(handles.ylabel_text_e, '%')) == 0;
    perc = [];
    perc = strfind(handles.ylabel_text_e, '%');
    len = length(handles.ylabel_text_e);
    Saved_options(16,1) = {strcat(handles.ylabel_text_e(1:perc(1)), handles.ylabel_text_e(perc(1):len))};
else
    Saved_options(16,1) = {handles.ylabel_text_e};
end

Saved_options(17,1) = {handles.title_text_e};
Saved_options(18,1) = {handles.x_axis_units_e};

[filename, pathname] = uiputfile({'*.dat'}, 'Save options');
if isnumeric(filename) == 1 || isnumeric(pathname) == 1
    
else
    dlmcell([pathname filename], Saved_options);
end

% --------------------------------------------------------------------
function Load_Callback(hObject, eventdata, handles)
% hObject    handle to Load (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
[filename, pathname] = uigetfile('*.dat', 'Load options...');
if isequal(filename,0) || isequal(pathname,0)
       
else
    [opt] = textread([pathname filename],'%s','headerlines', 0,'delimiter', '\t', 'emptyvalue', NaN);
   
    if cell2num(opt(8)) == 1
    else
        handles.xmin_e = cell2num(opt(1));
        handles.xmax_e = cell2num(opt(2));
    end
    
    handles.ymin_e = str2double(opt(3));
    handles.ymax_e = str2double(opt(4));
    handles.show1_e = str2double(opt(5));
    handles.show2_e = str2double(opt(6));
    handles.show3_e = str2double(opt(7));
    handles.auto_lim_e = str2double(opt(8));
    handles.legend_text_1_e = opt(9);
    handles.legend_text_2_e = opt(10);
    handles.legend_text_3_e = opt(11);
    handles.legend_text_4_e = opt(12);
    handles.legend_text_5_e = opt(13);
    handles.legend_text_6_e = opt(14);
    handles.xlabel_text_e = opt(15);
    handles.ylabel_text_e = opt(16);
    handles.title_text_e = opt(17);
    handles.x_axis_units_e = str2double(opt(18));
end

% Refresh
set(handles.popupmenu_units, 'Value', handles.x_axis_units_e);
set(handles.edit_Xmin, 'String', num2str(handles.xmin_e));
set(handles.edit_Xmax, 'String', num2str(handles.xmax_e));
set(handles.edit_Ymin, 'String', num2str(handles.ymin_e));
set(handles.edit_Ymax, 'String', num2str(handles.ymax_e));
set(handles.checkbox_show1, 'Value', handles.show1_e);
set(handles.checkbox_show2, 'Value', handles.show2_e);
set(handles.checkbox_show3, 'Value', handles.show3_e);
set(handles.checkbox_X_auto_lim, 'Value', handles.auto_lim_e);
set(handles.edit_points1, 'String', handles.legend_text_1_e);
set(handles.edit_approx1, 'String', handles.legend_text_2_e);
set(handles.edit_points2, 'String', handles.legend_text_3_e);
set(handles.edit_approx2, 'String', handles.legend_text_4_e);
set(handles.edit_points3, 'String', handles.legend_text_5_e);
set(handles.edit_approx3, 'String', handles.legend_text_6_e);
set(handles.edit_Xlabel, 'String', handles.xlabel_text_e);
set(handles.edit_Ylabel, 'String', handles.ylabel_text_e);
set(handles.edit_title, 'String', handles.title_text_e);
handles.open = 0;

guidata(hObject, handles);

Contact us