function varargout = funcslider(varargin)
% FUNCSLIDER Function Slider GUI
%      
%      FUNCSLIDER is a utility to vary input arguments (up to 5)
%      continuously using slider bars, and then evaluating a function based
%      on the output. The default limits of the slider bars are [0 -> 1],
%      but may be changed.
%      Input Function is a function handle (it must start with @).
%      The structure of the function will be analyzed to give an assumed
%      format of [z1,z2,..] = f(x1,x2,...) based on the number of input
%      and output arguments.
%      Output function is any valid MATLAB expression involving the output
%      variables [z1,z2,...]
%       
%      FUNCSLIDER starts the GUI populating the fields with demo values.
%
%      FUNCSLIDER(F) starts the GUI with function handle F as the input
%      function, and an empty output function.
%
%      FUNCSLIDER(F,S) starts the GUI with function handle F as the input
%      function, and string S as the output function.
%
%      NOTE: Any of these values may be changed from inside the GUI.
%
%      EXAMPLES:
%        1. Running funcslider by itself will give a default example using
%           an anonymous function
%    
%             funcslider
%
%        2. This is an example using a surface plot:
%
%             funcslider(@example1,'surf(z1); camlight')
%
%        3. Here is an example that uses multiple output values:
%
%             funcslider(@example2,'plot(z1,z2)')
%
%        4. An example that uses three input values:
%
%             funcslider(@example3,'stem(z1)')
%
%        5. Here is another example using anonymous functions and data from
%           the workspace:
%
%             I = rand(101,101,101);
%             funcslider(@(k) I(:,:,1+round(100*k)) ,'imagesc(z1)')
%
%
%
%

%   Teja Muppirala
%   Copyright 2010 The MathWorks, Inc.
%   Version 1.0 2010/6/30

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @funcslider_OpeningFcn, ...
                   'gui_OutputFcn',  @funcslider_OutputFcn, ...
                   'gui_LayoutFcn',  @funcslider_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 funcslider is made visible.
function funcslider_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 funcslider (see VARARGIN)
if isempty(varargin)
    set(handles.edit_in,'string','@(x) x*sin(x*[1:100])')
    set(handles.edit_out,'string','plot(z1); grid on');
else
    fin = varargin{1};
    try; set(handles.edit_out,'string',varargin{2}); end
    fstring = func2str(fin);
    if fstring(1) ~= '@', fstring = ['@' fstring]; end
    set(handles.edit_in,'string',fstring);
end

fin = get(handles.edit_in,'string');

set(gcf,'units','normalized','interruptible','off');
set(gcf,'Name','Function Slider');

%set(handles.axes1,'nextplot','replacechildren');

for k = 1:5
    eval(['s(' num2str(k) ') = handles.slider' num2str(k) ';']);
end
setappdata(gcf,'s',s);

initialize(fin,handles);

% Choose default command line output for funcslider
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes funcslider wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = funcslider_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_in_Callback(hObject, eventdata, handles)
% hObject    handle to edit_in (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_in as text
%        str2double(get(hObject,'String')) returns contents of edit_in as a double
fin = get(handles.edit_in,'string');
try; initialize(fin,handles);
catch; disp(lasterr);
end

% --- Executes during object creation, after setting all properties.
function edit_in_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_in (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



function edit_out_Callback(hObject, eventdata, handles)
% hObject    handle to edit_out (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_out as text
%        str2double(get(hObject,'String')) returns contents of edit_out as a double


% --- Executes during object creation, after setting all properties.
function edit_out_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_out (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 slider1_Callback(hObject, eventdata, handles)
slidermove(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


% --- Executes on slider movement.
function slider2_Callback(hObject, eventdata, handles)
slidermove(handles)

% --- 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


% --- Executes on slider movement.
function slider3_Callback(hObject, eventdata, handles)
slidermove(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


% --- Executes on slider movement.
function slider4_Callback(hObject, eventdata, handles)
slidermove(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


% --- Executes on slider movement.
function slider5_Callback(hObject, eventdata, handles)
slidermove(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



function edit_min1_Callback(hObject, eventdata, handles)
% hObject    handle to edit_min1 (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_min1 as text
%        str2double(get(hObject,'String')) returns contents of edit_min1 as a double
adj_sliderlevels(handles,1);

% --- Executes during object creation, after setting all properties.
function edit_min1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_min1 (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



function edit_min2_Callback(hObject, eventdata, handles)
adj_sliderlevels(handles,2);

% --- Executes during object creation, after setting all properties.
function edit_min2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_min2 (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



function edit_min3_Callback(hObject, eventdata, handles)
adj_sliderlevels(handles,3);

% --- Executes during object creation, after setting all properties.
function edit_min3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_min3 (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



function edit_min4_Callback(hObject, eventdata, handles)
adj_sliderlevels(handles,4);

% --- Executes during object creation, after setting all properties.
function edit_min4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_min4 (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



function edit_min5_Callback(hObject, eventdata, handles)
adj_sliderlevels(handles,5);

% --- Executes during object creation, after setting all properties.
function edit_min5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_min5 (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



function edit_max1_Callback(hObject, eventdata, handles)
adj_sliderlevels(handles,1);

% --- Executes during object creation, after setting all properties.
function edit_max1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_max1 (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



function edit_max2_Callback(hObject, eventdata, handles)
adj_sliderlevels(handles,2);

% --- Executes during object creation, after setting all properties.
function edit_max2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_max2 (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



function edit_max3_Callback(hObject, eventdata, handles)
adj_sliderlevels(handles,3);

% --- Executes during object creation, after setting all properties.
function edit_max3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_max3 (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



function edit_max4_Callback(hObject, eventdata, handles)
sadj_sliderlevels(handles,4);

% --- Executes during object creation, after setting all properties.
function edit_max4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_max4 (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



function edit_max5_Callback(hObject, eventdata, handles)
adj_sliderlevels(handles,1);

% --- Executes during object creation, after setting all properties.
function edit_max5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_max5 (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

function edit_val1_Callback(hObject, eventdata, handles)
adj_sliderlevels(handles,1);

% --- Executes during object creation, after setting all properties.
function edit_val1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_val1 (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



function edit_val2_Callback(hObject, eventdata, handles)
adj_sliderlevels(handles,2);

% --- Executes during object creation, after setting all properties.
function edit_val2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_val2 (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



function edit_val3_Callback(hObject, eventdata, handles)
adj_sliderlevels(handles,3);

% --- Executes during object creation, after setting all properties.
function edit_val3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_val3 (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



function edit_val4_Callback(hObject, eventdata, handles)
adj_sliderlevels(handles,4);

% --- Executes during object creation, after setting all properties.
function edit_val4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_val4 (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



function edit_val5_Callback(hObject, eventdata, handles)
adj_sliderlevels(handles,5);

% --- Executes during object creation, after setting all properties.
function edit_val5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_val5 (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

function slidermove(handles)
    s = getappdata(gcbf,'s');
    invals = getappdata(gcbf,'invals');
    outvals = getappdata(gcbf,'outvals');
    s = s(1:invals);
    
    p = get(s,'value');
    if isequal(p, get(gcf,'userdata'))
        return
    end
    
    if get(handles.checkbox1,'value')
        curxlim = xlim;
    end
    if get(handles.checkbox2,'value')
        curylim = ylim;
    end
    if get(handles.checkbox3,'value')
        curzlim = zlim;
    end
    if get(handles.checkbox4,'value')
        ct0 = get(gca,'cameratarget');
        cu0 = get(gca,'cameraupvector');
        cp0 = get(gca,'cameraposition');
        cv0 = get(gca,'cameraview');
        da0 = get(gca,'dataaspectratio');
        [AZ,EL] = view;
    end
    
    h_out = handles.edit_out;
    
    fin = getappdata(gcf,'fin');
    fstring = '[z1';
    for k = 2:outvals
        fstring = [fstring ',z' num2str(k)];
    end
    
    try
    if iscell(p)
        %z = feval(fin,p{:});
        eval([fstring '] = feval(fin,p{:});']);
    else
        %z = feval(fin,p);
        eval([fstring '] = feval(fin,p);']);
    end
    catch, disp(lasterr)
    end
    
    set(handles.text1,'string',evalc('whos z*'));
    
    
    
    try; eval(get(h_out,'string')); catch; disp(lasterr); end
    
    %Adjust the limits if needed
    if get(handles.checkbox1,'value')
        xlim(curxlim)
    end
    if get(handles.checkbox2,'value')
        ylim(curylim);
    end
    if get(handles.checkbox3,'value')
        zlim(curzlim);
    end
    if get(handles.checkbox4,'value')
        view(AZ,EL);
        set(gca,'cameratarget',ct0);
        set(gca,'cameraupvector',cu0);
        set(gca,'cameraposition',cp0);
        set(gca,'cameraview',cv0);
        set(gca,'dataaspectratio',da0);
    end
    
    drawnow;

    for k = 1:invals
        hsli = eval(['handles.slider' num2str(k)]);
        hval = eval(['handles.edit_val' num2str(k)]);
        set(hval,'string',num2str(get(hsli,'value')));
    end
    
    set(gcf,'userdata',p);
        
function initialize(fin,handles)
if fin(1) ~= '@';
    errordlg('The input function should start with ''@''')
end
try fin = evalin('base',fin);
catch
        errordlg(lasterr);
        return
end
setappdata(gcf,'fin',fin);

invals = nargin(fin);
outvals = abs(nargout(fin));
setappdata(gcf,'invals',invals);
setappdata(gcf,'outvals',outvals);
s = getappdata(gcf,'s');

set(s(1:invals),'enable','on');
set(s(invals+1:5),'enable','off');

fstring = '(x1';
for k = 2:invals
    fstring = [fstring ',x' num2str(k)];
end
rhs = [fstring ')'];

fstring = '[z1';
for k = 2:outvals
    fstring = [fstring ',z' num2str(k)];
end
lhs = [fstring ']'];

set(handles.text14,'string',['Function structure:   ' lhs ' = f' rhs]);



% --- Executes on mouse motion over figure - except title and menu.
function figure1_WindowButtonMotionFcn(hObject, eventdata, handles)
slidermove(handles);

function adj_sliderlevels(handles,num)

hmin = eval(['handles.edit_min' num2str(num)]);
hmax = eval(['handles.edit_max' num2str(num)]);
hval = eval(['handles.edit_val' num2str(num)]);
hsli = eval(['handles.slider' num2str(num)]);

newmin = str2double(get(hmin, 'string'));
if ~isnumeric(newmin) || ~isfinite(newmin),
    newmin = 0;
end
newmax = str2double(get(hmax, 'string'));
if ~isnumeric(newmin) || ~isfinite(newmax),
    newmax = 0;
end
newval = str2double(get(hval, 'string'));
if ~isnumeric(newmin) || ~isfinite(newmax),
    newval = newmin;
end
if newval > newmax, newmax = newval;
    set(hmax,'string',num2str(newmax));
elseif newval < newmin, newmin = newval;
    set(hmin,'string',num2str(newmin));
end

set(hsli, 'min', newmin, 'max', newmax,'value',newval);

% --- 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)
if get(hObject,'Value')
    viewdata = getappdata(gcf,'viewdata');
    viewdata(1,:) = xlim;
    setappdata(gcf,'viewdata',viewdata);
end

% Hint: get(hObject,'Value') returns toggle state of checkbox1


% --- 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)
if get(hObject,'Value')
    viewdata = getappdata(gcf,'viewdata');
    viewdata(2,:) = ylim;
    setappdata(gcf,'viewdata',viewdata);
end
% Hint: get(hObject,'Value') returns toggle state of checkbox2


% --- 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)
if get(hObject,'Value')
    viewdata = getappdata(gcf,'viewdata');
    viewdata(3,:) = zlim;
    setappdata(gcf,'viewdata',viewdata);
end
% Hint: get(hObject,'Value') returns toggle state of checkbox3


% --- 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)
if get(hObject,'Value')
    viewdata = getappdata(gcf,'viewdata');
    [AZ,EL] = view; 
    viewdata(4,:) = [AZ,EL];
    setappdata(gcf,'viewdata',viewdata);
end
% Hint: get(hObject,'Value') returns toggle state of checkbox4


% --- 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)
cla reset;%(handles.axes1);
%view([0 90]);
%set(handles.axes1,'nextplot','replacechildren');


% --- Creates and returns a handle to the GUI figure. 
function h1 = funcslider_LayoutFcn(policy)
% policy - create a new figure or use a singleton. 'new' or 'reuse'.

persistent hsingleton;
if strcmpi(policy, 'reuse') & ishandle(hsingleton)
    h1 = hsingleton;
    return;
end

appdata = [];
appdata.GUIDEOptions = struct(...
    'active_h', [], ...
    'taginfo', struct(...
    'figure', 2, ...
    'edit', 18, ...
    'slider', 6, ...
    'text', 15, ...
    'listbox', 2, ...
    'axes', 2, ...
    'checkbox', 5, ...
    'pushbutton', 2), ...
    'override', 1, ...
    'release', 13, ...
    'resize', 'simple', ...
    'accessibility', 'callback', ...
    'mfile', 1, ...
    'callbacks', 1, ...
    'singleton', 1, ...
    'syscolorfig', 1, ...
    'blocking', 0, ...
    'lastSavedFile', 'C:\MATLAB\Work\100623_varslider\Version1p0\funcslider.m', ...
    'lastFilename', 'C:\MATLAB\Work\100623_varslider\fcnslider.fig');
appdata.lastValidTag = 'figure1';
appdata.GUIDELayoutEditor = [];
appdata.initTags = struct(...
    'handle', [], ...
    'tag', 'figure1');

h1 = figure(...
'Units','characters',...
'PaperUnits',get(0,'defaultfigurePaperUnits'),...
'Color',[0.831372549019608 0.815686274509804 0.784313725490196],...
'Colormap',[0 0 0.5625;0 0 0.625;0 0 0.6875;0 0 0.75;0 0 0.8125;0 0 0.875;0 0 0.9375;0 0 1;0 0.0625 1;0 0.125 1;0 0.1875 1;0 0.25 1;0 0.3125 1;0 0.375 1;0 0.4375 1;0 0.5 1;0 0.5625 1;0 0.625 1;0 0.6875 1;0 0.75 1;0 0.8125 1;0 0.875 1;0 0.9375 1;0 1 1;0.0625 1 1;0.125 1 0.9375;0.1875 1 0.875;0.25 1 0.8125;0.3125 1 0.75;0.375 1 0.6875;0.4375 1 0.625;0.5 1 0.5625;0.5625 1 0.5;0.625 1 0.4375;0.6875 1 0.375;0.75 1 0.3125;0.8125 1 0.25;0.875 1 0.1875;0.9375 1 0.125;1 1 0.0625;1 1 0;1 0.9375 0;1 0.875 0;1 0.8125 0;1 0.75 0;1 0.6875 0;1 0.625 0;1 0.5625 0;1 0.5 0;1 0.4375 0;1 0.375 0;1 0.3125 0;1 0.25 0;1 0.1875 0;1 0.125 0;1 0.0625 0;1 0 0;0.9375 0 0;0.875 0 0;0.8125 0 0;0.75 0 0;0.6875 0 0;0.625 0 0;0.5625 0 0],...
'IntegerHandle','off',...
'InvertHardcopy',get(0,'defaultfigureInvertHardcopy'),...
'MenuBar','none',...
'Name','fcnslider',...
'NumberTitle','off',...
'PaperPosition',get(0,'defaultfigurePaperPosition'),...
'PaperSize',get(0,'defaultfigurePaperSize'),...
'PaperType',get(0,'defaultfigurePaperType'),...
'Position',[103.666666666667 8.91666666666667 107.833333333333 52.5833333333333],...
'ToolBar','figure',...
'WindowButtonMotionFcn',@(hObject,eventdata)funcslider('figure1_WindowButtonMotionFcn',hObject,eventdata,guidata(hObject)),...
'HandleVisibility','callback',...
'Tag','figure1',...
'UserData',[],...
'Visible','on',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'edit_in';

h2 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)funcslider('edit_in_Callback',hObject,eventdata,guidata(hObject)),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'HorizontalAlignment','left',...
'Position',[0.12210200927357 0.141045958795563 0.217928902627512 0.0332805071315372],...
'String',blanks(0),...
'Style','edit',...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)funcslider('edit_in_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'Tag','edit_in');

appdata = [];
appdata.lastValidTag = 'edit_out';

h3 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)funcslider('edit_out_Callback',hObject,eventdata,guidata(hObject)),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'HorizontalAlignment','left',...
'Position',[0.523956723338485 0.141045958795563 0.217928902627512 0.0332805071315372],...
'String',blanks(0),...
'Style','edit',...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)funcslider('edit_out_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'Tag','edit_out');

appdata = [];
appdata.lastValidTag = 'slider1';

h4 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[0.9 0.9 0.9],...
'Callback',@(hObject,eventdata)funcslider('slider1_Callback',hObject,eventdata,guidata(hObject)),...
'CData',[],...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'Position',[0.106646058732612 0.318541996830428 0.712519319938176 0.0316957210776545],...
'String',{  'スライダ' },...
'Style','slider',...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)funcslider('slider1_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'Tag','slider1',...
'UserData',[]);

appdata = [];
appdata.lastValidTag = 'slider2';

h5 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[0.9 0.9 0.9],...
'Callback',@(hObject,eventdata)funcslider('slider2_Callback',hObject,eventdata,guidata(hObject)),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'Position',[0.106646058732612 0.286846275752773 0.712519319938176 0.0316957210776545],...
'String',{  'スライダ' },...
'Style','slider',...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)funcslider('slider2_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'Tag','slider2');

appdata = [];
appdata.lastValidTag = 'slider3';

h6 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[0.9 0.9 0.9],...
'Callback',@(hObject,eventdata)funcslider('slider3_Callback',hObject,eventdata,guidata(hObject)),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'Position',[0.106646058732612 0.255150554675119 0.712519319938176 0.0316957210776545],...
'String',{  'スライダ' },...
'Style','slider',...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)funcslider('slider3_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'Tag','slider3');

appdata = [];
appdata.lastValidTag = 'slider4';

h7 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[0.9 0.9 0.9],...
'Callback',@(hObject,eventdata)funcslider('slider4_Callback',hObject,eventdata,guidata(hObject)),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'Position',[0.106646058732612 0.223454833597464 0.712519319938176 0.0316957210776545],...
'String',{  'スライダ' },...
'Style','slider',...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)funcslider('slider4_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'Tag','slider4');

appdata = [];
appdata.lastValidTag = 'slider5';

h8 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[0.9 0.9 0.9],...
'Callback',@(hObject,eventdata)funcslider('slider5_Callback',hObject,eventdata,guidata(hObject)),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'Position',[0.106646058732612 0.19175911251981 0.712519319938176 0.0316957210776545],...
'String',{  'スライダ' },...
'Style','slider',...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)funcslider('slider5_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'Tag','slider5');

appdata = [];
appdata.lastValidTag = 'edit_min1';

h9 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)funcslider('edit_min1_Callback',hObject,eventdata,guidata(hObject)),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'Position',[0.0293663060278207 0.322325569817708 0.0633693972179289 0.0338032376100431],...
'String','0',...
'Style','edit',...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)funcslider('edit_min1_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'Tag','edit_min1');

appdata = [];
appdata.lastValidTag = 'edit_min2';

h10 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)funcslider('edit_min2_Callback',hObject,eventdata,guidata(hObject)),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'Position',[0.0293663060278207 0.290132010189096 0.0633693972179289 0.0338032376100431],...
'String','0',...
'Style','edit',...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)funcslider('edit_min2_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'Tag','edit_min2');

appdata = [];
appdata.lastValidTag = 'edit_min3';

h11 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)funcslider('edit_min3_Callback',hObject,eventdata,guidata(hObject)),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'Position',[0.0293663060278207 0.259548128541914 0.0633693972179289 0.0338032376100431],...
'String','0',...
'Style','edit',...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)funcslider('edit_min3_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'Tag','edit_min3');

appdata = [];
appdata.lastValidTag = 'edit_min4';

h12 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)funcslider('edit_min4_Callback',hObject,eventdata,guidata(hObject)),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'Position',[0.0293663060278207 0.228939354967184 0.0633693972179289 0.0338032376100431],...
'String','0',...
'Style','edit',...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)funcslider('edit_min4_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'Tag','edit_min4');

appdata = [];
appdata.lastValidTag = 'edit_min5';

h13 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)funcslider('edit_min5_Callback',hObject,eventdata,guidata(hObject)),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'Position',[0.0293663060278207 0.196745795338572 0.0633693972179289 0.0338032376100431],...
'String','0',...
'Style','edit',...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)funcslider('edit_min5_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'Tag','edit_min5');

appdata = [];
appdata.lastValidTag = 'edit_max1';

h14 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)funcslider('edit_max1_Callback',hObject,eventdata,guidata(hObject)),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'Position',[0.83307573415765 0.320715891836277 0.0633693972179289 0.0338032376100431],...
'String','1',...
'Style','edit',...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)funcslider('edit_max1_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'Tag','edit_max1');

appdata = [];
appdata.lastValidTag = 'edit_max2';

h15 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)funcslider('edit_max2_Callback',hObject,eventdata,guidata(hObject)),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'Position',[0.83307573415765 0.288522332207665 0.0633693972179289 0.0338032376100431],...
'String','1',...
'Style','edit',...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)funcslider('edit_max2_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'Tag','edit_max2');

appdata = [];
appdata.lastValidTag = 'edit_max3';

h16 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)funcslider('edit_max3_Callback',hObject,eventdata,guidata(hObject)),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'Position',[0.83307573415765 0.257938450560483 0.0633693972179289 0.0338032376100431],...
'String','1',...
'Style','edit',...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)funcslider('edit_max3_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'Tag','edit_max3');

appdata = [];
appdata.lastValidTag = 'edit_max4';

h17 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)funcslider('edit_max4_Callback',hObject,eventdata,guidata(hObject)),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'Position',[0.83307573415765 0.225744890931871 0.0633693972179289 0.0338032376100431],...
'String','1',...
'Style','edit',...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)funcslider('edit_max4_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'Tag','edit_max4');

appdata = [];
appdata.lastValidTag = 'edit_max5';

h18 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)funcslider('edit_max5_Callback',hObject,eventdata,guidata(hObject)),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'Position',[0.83307573415765 0.193551331303258 0.0633693972179289 0.0338032376100431],...
'String','1',...
'Style','edit',...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)funcslider('edit_max5_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'Tag','edit_max5');

appdata = [];
appdata.lastValidTag = 'text1';

h19 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',8,...
'HorizontalAlignment','left',...
'Max',1000000,...
'Position',[0.0139103554868624 0.0142630744849445 0.727975270479134 0.080824088748019],...
'String','Output data type',...
'Style','edit',...
'Tag','text1',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'axes1';

h20 = axes(...
'Parent',h1,...
'Position',[0.0293663060278207 0.458003169572108 0.94435857805255 0.507131537242472],...
'CameraPosition',[0.5 0.5 9.16025403784439],...
'CameraPositionMode',get(0,'defaultaxesCameraPositionMode'),...
'Color',get(0,'defaultaxesColor'),...
'ColorOrder',get(0,'defaultaxesColorOrder'),...
'FontName',get(0,'defaultaxesFontName'),...
'FontSize',get(0,'defaultaxesFontSize'),...
'LooseInset',[0.0567146509183546 0.0398395126424734 0.0414453218249514 0.0271633040744137],...
'XColor',get(0,'defaultaxesXColor'),...
'YColor',get(0,'defaultaxesYColor'),...
'ZColor',get(0,'defaultaxesZColor'),...
'Tag','axes1',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

h21 = get(h20,'title');

set(h21,...
'Parent',h20,...
'Units','data',...
'FontUnits','points',...
'BackgroundColor','none',...
'Color',[0 0 0],...
'DisplayName',blanks(0),...
'EdgeColor','none',...
'EraseMode','normal',...
'DVIMode','auto',...
'FontAngle','normal',...
'FontName','MS UI Gothic',...
'FontSize',9,...
'FontWeight','normal',...
'HorizontalAlignment','center',...
'LineStyle','-',...
'LineWidth',0.5,...
'Margin',2,...
'Position',[0.5 1.0140625 1.00005459937205],...
'Rotation',0,...
'String',blanks(0),...
'Interpreter','tex',...
'VerticalAlignment','bottom',...
'ButtonDownFcn',[],...
'CreateFcn', {@local_CreateFcn, [], ''} ,...
'DeleteFcn',[],...
'BusyAction','queue',...
'HandleVisibility','off',...
'HelpTopicKey',blanks(0),...
'HitTest','on',...
'Interruptible','on',...
'SelectionHighlight','on',...
'Serializable','on',...
'Tag',blanks(0),...
'UserData',[],...
'Visible','on',...
'XLimInclude','on',...
'YLimInclude','on',...
'ZLimInclude','on',...
'CLimInclude','on',...
'ALimInclude','on',...
'IncludeRenderer','on',...
'Clipping','off');

h22 = get(h20,'xlabel');

set(h22,...
'Parent',h20,...
'Units','data',...
'FontUnits','points',...
'BackgroundColor','none',...
'Color',[0 0 0],...
'DisplayName',blanks(0),...
'EdgeColor','none',...
'EraseMode','normal',...
'DVIMode','auto',...
'FontAngle','normal',...
'FontName','MS UI Gothic',...
'FontSize',9,...
'FontWeight','normal',...
'HorizontalAlignment','center',...
'LineStyle','-',...
'LineWidth',0.5,...
'Margin',2,...
'Position',[0.498363338788871 -0.0640625000000001 1.00005459937205],...
'Rotation',0,...
'String',blanks(0),...
'Interpreter','tex',...
'VerticalAlignment','cap',...
'ButtonDownFcn',[],...
'CreateFcn', {@local_CreateFcn, [], ''} ,...
'DeleteFcn',[],...
'BusyAction','queue',...
'HandleVisibility','off',...
'HelpTopicKey',blanks(0),...
'HitTest','on',...
'Interruptible','on',...
'SelectionHighlight','on',...
'Serializable','on',...
'Tag',blanks(0),...
'UserData',[],...
'Visible','on',...
'XLimInclude','on',...
'YLimInclude','on',...
'ZLimInclude','on',...
'CLimInclude','on',...
'ALimInclude','on',...
'IncludeRenderer','on',...
'Clipping','off');

h23 = get(h20,'ylabel');

set(h23,...
'Parent',h20,...
'Units','data',...
'FontUnits','points',...
'BackgroundColor','none',...
'Color',[0 0 0],...
'DisplayName',blanks(0),...
'EdgeColor','none',...
'EraseMode','normal',...
'DVIMode','auto',...
'FontAngle','normal',...
'FontName','MS UI Gothic',...
'FontSize',9,...
'FontWeight','normal',...
'HorizontalAlignment','center',...
'LineStyle','-',...
'LineWidth',0.5,...
'Margin',2,...
'Position',[-0.0400981996726678 0.4953125 1.00005459937205],...
'Rotation',90,...
'String',blanks(0),...
'Interpreter','tex',...
'VerticalAlignment','bottom',...
'ButtonDownFcn',[],...
'CreateFcn', {@local_CreateFcn, [], ''} ,...
'DeleteFcn',[],...
'BusyAction','queue',...
'HandleVisibility','off',...
'HelpTopicKey',blanks(0),...
'HitTest','on',...
'Interruptible','on',...
'SelectionHighlight','on',...
'Serializable','on',...
'Tag',blanks(0),...
'UserData',[],...
'Visible','on',...
'XLimInclude','on',...
'YLimInclude','on',...
'ZLimInclude','on',...
'CLimInclude','on',...
'ALimInclude','on',...
'IncludeRenderer','on',...
'Clipping','off');

h24 = get(h20,'zlabel');

set(h24,...
'Parent',h20,...
'Units','data',...
'FontUnits','points',...
'BackgroundColor','none',...
'Color',[0 0 0],...
'DisplayName',blanks(0),...
'EdgeColor','none',...
'EraseMode','normal',...
'DVIMode','auto',...
'FontAngle','normal',...
'FontName','MS UI Gothic',...
'FontSize',9,...
'FontWeight','normal',...
'HorizontalAlignment','right',...
'LineStyle','-',...
'LineWidth',0.5,...
'Margin',2,...
'Position',[-0.0319148936170213 1.0640625 1.00005459937205],...
'Rotation',0,...
'String',blanks(0),...
'Interpreter','tex',...
'VerticalAlignment','middle',...
'ButtonDownFcn',[],...
'CreateFcn', {@local_CreateFcn, [], ''} ,...
'DeleteFcn',[],...
'BusyAction','queue',...
'HandleVisibility','off',...
'HelpTopicKey',blanks(0),...
'HitTest','on',...
'Interruptible','on',...
'SelectionHighlight','on',...
'Serializable','on',...
'Tag',blanks(0),...
'UserData',[],...
'Visible','off',...
'XLimInclude','on',...
'YLimInclude','on',...
'ZLimInclude','on',...
'CLimInclude','on',...
'ALimInclude','on',...
'IncludeRenderer','on',...
'Clipping','off');

appdata = [];
appdata.lastValidTag = 'text2';

h25 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'HorizontalAlignment','left',...
'Position',[0.0139103554868624 0.135 0.0942812982998454 0.0332805071315372],...
'String','Input fcn:',...
'Style','text',...
'Tag','text2',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'text3';

h26 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'HorizontalAlignment','left',...
'Position',[0.42 0.135 0.0942812982998454 0.0332805071315372],...
'String','Output fcn:',...
'Style','text',...
'Tag','text3',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'edit_val1';

h27 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)funcslider('edit_val1_Callback',hObject,eventdata,guidata(hObject)),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'Position',[0.924265842349305 0.320715891836277 0.0633693972179289 0.0338032376100431],...
'String',blanks(0),...
'Style','edit',...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)funcslider('edit_val1_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'Tag','edit_val1');

appdata = [];
appdata.lastValidTag = 'edit_val2';

h28 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)funcslider('edit_val2_Callback',hObject,eventdata,guidata(hObject)),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'Position',[0.924265842349305 0.288522332207665 0.0633693972179289 0.0338032376100431],...
'String',blanks(0),...
'Style','edit',...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)funcslider('edit_val2_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'Tag','edit_val2');

appdata = [];
appdata.lastValidTag = 'edit_val3';

h29 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)funcslider('edit_val3_Callback',hObject,eventdata,guidata(hObject)),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'Position',[0.924265842349305 0.257938450560483 0.0633693972179289 0.0338032376100431],...
'String',blanks(0),...
'Style','edit',...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)funcslider('edit_val3_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'Tag','edit_val3');

appdata = [];
appdata.lastValidTag = 'edit_val4';

h30 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)funcslider('edit_val4_Callback',hObject,eventdata,guidata(hObject)),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'Position',[0.924265842349305 0.225744890931871 0.0633693972179289 0.0338032376100431],...
'String',blanks(0),...
'Style','edit',...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)funcslider('edit_val4_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'Tag','edit_val4');

appdata = [];
appdata.lastValidTag = 'edit_val5';

h31 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)funcslider('edit_val5_Callback',hObject,eventdata,guidata(hObject)),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'Position',[0.924265842349305 0.193551331303258 0.0633693972179289 0.0338032376100431],...
'String',blanks(0),...
'Style','edit',...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)funcslider('edit_val5_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'Tag','edit_val5');

appdata = [];
appdata.lastValidTag = 'text5';

h32 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'Position',[0.0278207109737249 0.357738485409182 0.0633693972179289 0.0225354917400287],...
'String','Min',...
'Style','text',...
'Tag','text5',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'text6';

h33 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'Position',[0.83307573415765 0.356128807427751 0.0633693972179289 0.0225354917400287],...
'String','Max',...
'Style','text',...
'Tag','text6',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'text7';

h34 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'Position',[0.924265842349305 0.356128807427751 0.0633693972179289 0.0225354917400287],...
'String','Value',...
'Style','text',...
'Tag','text7',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'checkbox1';

h35 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'Callback',@(hObject,eventdata)funcslider('checkbox1_Callback',hObject,eventdata,guidata(hObject)),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'Position',[0.199381761978362 0.370615909260627 0.0494590417310665 0.0370225935729043],...
'String','x',...
'Style','checkbox',...
'Tag','checkbox1',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'checkbox2';

h36 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'Callback',@(hObject,eventdata)funcslider('checkbox2_Callback',hObject,eventdata,guidata(hObject)),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'Position',[0.261205564142195 0.370615909260627 0.0494590417310665 0.0370225935729043],...
'String','y',...
'Style','checkbox',...
'Tag','checkbox2',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'checkbox3';

h37 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'Callback',@(hObject,eventdata)funcslider('checkbox3_Callback',hObject,eventdata,guidata(hObject)),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'Position',[0.323029366306028 0.370615909260627 0.0494590417310665 0.0370225935729043],...
'String','z',...
'Style','checkbox',...
'Tag','checkbox3',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'checkbox4';

h38 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'Callback',@(hObject,eventdata)funcslider('checkbox4_Callback',hObject,eventdata,guidata(hObject)),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'Position',[0.384853168469861 0.370615909260627 0.153013910355487 0.0370225935729043],...
'String','viewing angle',...
'Style','checkbox',...
'Tag','checkbox4',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'text8';

h39 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'Position',[0.123647604327666 0.37866429916778 0.0633693972179289 0.0209258137585981],...
'String','Lock:',...
'Style','text',...
'Tag','text8',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'pushbutton1';

h40 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'Callback',@(hObject,eventdata)funcslider('pushbutton1_Callback',hObject,eventdata,guidata(hObject)),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'Position',[0.777434312210201 0.0142630744849445 0.205564142194745 0.160063391442155],...
'String','Reset Axes',...
'Tag','pushbutton1',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'text9';

h41 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'HorizontalAlignment','left',...
'Position',[-0.00154559505409583 0.328050713153724 0.0231839258114374 0.0206022187004754],...
'String','x1',...
'Style','text',...
'Tag','text9',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'text10';

h42 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'HorizontalAlignment','left',...
'Position',[-0.00154559505409583 0.29635499207607 0.0231839258114374 0.0221870047543582],...
'String','x2',...
'Style','text',...
'Tag','text10',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'text11';

h43 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'HorizontalAlignment','left',...
'Position',[-0.00154559505409583 0.264659270998415 0.0231839258114374 0.0206022187004754],...
'String','x3',...
'Style','text',...
'Tag','text11',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'text12';

h44 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'HorizontalAlignment','left',...
'Position',[-0.00154559505409583 0.232963549920761 0.0231839258114374 0.0206022187004754],...
'String','x4',...
'Style','text',...
'Tag','text12',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'text13';

h45 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'HorizontalAlignment','left',...
'Position',[-0.00154559505409583 0.199683042789223 0.0231839258114374 0.0206022187004754],...
'String','x5',...
'Style','text',...
'Tag','text13',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'text14';

h46 = uicontrol(...
'Parent',h1,...
'Units','normalized',...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'HorizontalAlignment','left',...
'Position',[0.0139103554868624 0.106180665610143 0.72952086553323 0.0206022187004754],...
'String','Current equation: ',...
'Style','text',...
'Tag','text14',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );


hsingleton = h1;


% --- Set application data first then calling the CreateFcn. 
function local_CreateFcn(hObject, eventdata, createfcn, appdata)

if ~isempty(appdata)
   names = fieldnames(appdata);
   for i=1:length(names)
       name = char(names(i));
       setappdata(hObject, name, getfield(appdata,name));
   end
end

if ~isempty(createfcn)
   if isa(createfcn,'function_handle')
       createfcn(hObject, eventdata);
   else
       eval(createfcn);
   end
end


% --- Handles default GUIDE GUI creation and callback dispatch
function varargout = gui_mainfcn(gui_State, varargin)

gui_StateFields =  {'gui_Name'
    'gui_Singleton'
    'gui_OpeningFcn'
    'gui_OutputFcn'
    'gui_LayoutFcn'
    'gui_Callback'};
gui_Mfile = '';
for i=1:length(gui_StateFields)
    if ~isfield(gui_State, gui_StateFields{i})
        error('MATLAB:gui_mainfcn:FieldNotFound', 'Could not find field %s in the gui_State struct in GUI M-file %s', gui_StateFields{i}, gui_Mfile);
    elseif isequal(gui_StateFields{i}, 'gui_Name')
        gui_Mfile = [gui_State.(gui_StateFields{i}), '.m'];
    end
end

numargin = length(varargin);

if numargin == 0
    % FUNCSLIDER
    % create the GUI only if we are not in the process of loading it
    % already
    gui_Create = true;
elseif local_isInvokeActiveXCallback(gui_State, varargin{:})
    % FUNCSLIDER(ACTIVEX,...)
    vin{1} = gui_State.gui_Name;
    vin{2} = [get(varargin{1}.Peer, 'Tag'), '_', varargin{end}];
    vin{3} = varargin{1};
    vin{4} = varargin{end-1};
    vin{5} = guidata(varargin{1}.Peer);
    feval(vin{:});
    return;
elseif local_isInvokeHGCallback(gui_State, varargin{:})
    % FUNCSLIDER('CALLBACK',hObject,eventData,handles,...)
    gui_Create = false;
else
    % FUNCSLIDER(...)
    % create the GUI and hand varargin to the openingfcn
    gui_Create = true;
end

if ~gui_Create
    % In design time, we need to mark all components possibly created in
    % the coming callback evaluation as non-serializable. This way, they
    % will not be brought into GUIDE and not be saved in the figure file
    % when running/saving the GUI from GUIDE.
    designEval = false;
    if (numargin>1 && ishghandle(varargin{2}))
        fig = varargin{2};
        while ~isempty(fig) && ~isa(handle(fig),'figure')
            fig = get(fig,'parent');
        end
        
        designEval = isappdata(0,'CreatingGUIDEFigure') || isprop(fig,'__GUIDEFigure');
    end
        
    if designEval
        beforeChildren = findall(fig);
    end
    
    % evaluate the callback now
    varargin{1} = gui_State.gui_Callback;
    if nargout
        [varargout{1:nargout}] = feval(varargin{:});
    else       
        feval(varargin{:});
    end
    
    % Set serializable of objects created in the above callback to off in
    % design time. Need to check whether figure handle is still valid in
    % case the figure is deleted during the callback dispatching.
    if designEval && ishandle(fig)
        set(setdiff(findall(fig),beforeChildren), 'Serializable','off');
    end
else
    if gui_State.gui_Singleton
        gui_SingletonOpt = 'reuse';
    else
        gui_SingletonOpt = 'new';
    end

    % Check user passing 'visible' P/V pair first so that its value can be
    % used by oepnfig to prevent flickering
    gui_Visible = 'auto';
    gui_VisibleInput = '';
    for index=1:2:length(varargin)
        if length(varargin) == index || ~ischar(varargin{index})
            break;
        end

        % Recognize 'visible' P/V pair
        len1 = min(length('visible'),length(varargin{index}));
        len2 = min(length('off'),length(varargin{index+1}));
        if ischar(varargin{index+1}) && strncmpi(varargin{index},'visible',len1) && len2 > 1
            if strncmpi(varargin{index+1},'off',len2)
                gui_Visible = 'invisible';
                gui_VisibleInput = 'off';
            elseif strncmpi(varargin{index+1},'on',len2)
                gui_Visible = 'visible';
                gui_VisibleInput = 'on';
            end
        end
    end
    
    % Open fig file with stored settings.  Note: This executes all component
    % specific CreateFunctions with an empty HANDLES structure.

    
    % Do feval on layout code in m-file if it exists
    gui_Exported = ~isempty(gui_State.gui_LayoutFcn);
    % this application data is used to indicate the running mode of a GUIDE
    % GUI to distinguish it from the design mode of the GUI in GUIDE. it is
    % only used by actxproxy at this time.   
    setappdata(0,genvarname(['OpenGuiWhenRunning_', gui_State.gui_Name]),1);
    if gui_Exported
        gui_hFigure = feval(gui_State.gui_LayoutFcn, gui_SingletonOpt);

        % make figure invisible here so that the visibility of figure is
        % consistent in OpeningFcn in the exported GUI case
        if isempty(gui_VisibleInput)
            gui_VisibleInput = get(gui_hFigure,'Visible');
        end
        set(gui_hFigure,'Visible','off')

        % openfig (called by local_openfig below) does this for guis without
        % the LayoutFcn. Be sure to do it here so guis show up on screen.
        movegui(gui_hFigure,'onscreen');
    else
        gui_hFigure = local_openfig(gui_State.gui_Name, gui_SingletonOpt, gui_Visible);
        % If the figure has InGUIInitialization it was not completely created
        % on the last pass.  Delete this handle and try again.
        if isappdata(gui_hFigure, 'InGUIInitialization')
            delete(gui_hFigure);
            gui_hFigure = local_openfig(gui_State.gui_Name, gui_SingletonOpt, gui_Visible);
        end
    end
    if isappdata(0, genvarname(['OpenGuiWhenRunning_', gui_State.gui_Name]))
        rmappdata(0,genvarname(['OpenGuiWhenRunning_', gui_State.gui_Name]));
    end

    % Set flag to indicate starting GUI initialization
    setappdata(gui_hFigure,'InGUIInitialization',1);

    % Fetch GUIDE Application options
    gui_Options = getappdata(gui_hFigure,'GUIDEOptions');
    % Singleton setting in the GUI M-file takes priority if different
    gui_Options.singleton = gui_State.gui_Singleton;

    if ~isappdata(gui_hFigure,'GUIOnScreen')
        % Adjust background color
        if gui_Options.syscolorfig
            set(gui_hFigure,'Color', get(0,'DefaultUicontrolBackgroundColor'));
        end

        % Generate HANDLES structure and store with GUIDATA. If there is
        % user set GUI data already, keep that also.
        data = guidata(gui_hFigure);
        handles = guihandles(gui_hFigure);
        if ~isempty(handles)
            if isempty(data)
                data = handles;
            else
                names = fieldnames(handles);
                for k=1:length(names)
                    data.(char(names(k)))=handles.(char(names(k)));
                end
            end
        end
        guidata(gui_hFigure, data);
    end

    % Apply input P/V pairs other than 'visible'
    for index=1:2:length(varargin)
        if length(varargin) == index || ~ischar(varargin{index})
            break;
        end

        len1 = min(length('visible'),length(varargin{index}));
        if ~strncmpi(varargin{index},'visible',len1)
            try set(gui_hFigure, varargin{index}, varargin{index+1}), catch break, end
        end
    end

    % If handle visibility is set to 'callback', turn it on until finished
    % with OpeningFcn
    gui_HandleVisibility = get(gui_hFigure,'HandleVisibility');
    if strcmp(gui_HandleVisibility, 'callback')
        set(gui_hFigure,'HandleVisibility', 'on');
    end

    feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure), varargin{:});

    if isscalar(gui_hFigure) && ishandle(gui_hFigure)
        % Handle the default callbacks of predefined toolbar tools in this
        % GUI, if any
        guidemfile('restoreToolbarToolPredefinedCallback',gui_hFigure); 
        
        % Update handle visibility
        set(gui_hFigure,'HandleVisibility', gui_HandleVisibility);

        % Call openfig again to pick up the saved visibility or apply the
        % one passed in from the P/V pairs
        if ~gui_Exported
            gui_hFigure = local_openfig(gui_State.gui_Name, 'reuse',gui_Visible);
        elseif ~isempty(gui_VisibleInput)
            set(gui_hFigure,'Visible',gui_VisibleInput);
        end
        if strcmpi(get(gui_hFigure, 'Visible'), 'on')
            figure(gui_hFigure);
            
            if gui_Options.singleton
                setappdata(gui_hFigure,'GUIOnScreen', 1);
            end
        end

        % Done with GUI initialization
        if isappdata(gui_hFigure,'InGUIInitialization')
            rmappdata(gui_hFigure,'InGUIInitialization');
        end

        % If handle visibility is set to 'callback', turn it on until
        % finished with OutputFcn
        gui_HandleVisibility = get(gui_hFigure,'HandleVisibility');
        if strcmp(gui_HandleVisibility, 'callback')
            set(gui_hFigure,'HandleVisibility', 'on');
        end
        gui_Handles = guidata(gui_hFigure);
    else
        gui_Handles = [];
    end

    if nargout
        [varargout{1:nargout}] = feval(gui_State.gui_OutputFcn, gui_hFigure, [], gui_Handles);
    else
        feval(gui_State.gui_OutputFcn, gui_hFigure, [], gui_Handles);
    end

    if isscalar(gui_hFigure) && ishandle(gui_hFigure)
        set(gui_hFigure,'HandleVisibility', gui_HandleVisibility);
    end
end

function gui_hFigure = local_openfig(name, singleton, visible)

% openfig with three arguments was new from R13. Try to call that first, if
% failed, try the old openfig.
if nargin('openfig') == 2
    % OPENFIG did not accept 3rd input argument until R13,
    % toggle default figure visible to prevent the figure
    % from showing up too soon.
    gui_OldDefaultVisible = get(0,'defaultFigureVisible');
    set(0,'defaultFigureVisible','off');
    gui_hFigure = openfig(name, singleton);
    set(0,'defaultFigureVisible',gui_OldDefaultVisible);
else
    gui_hFigure = openfig(name, singleton, visible);
end

function result = local_isInvokeActiveXCallback(gui_State, varargin)

try
    result = ispc && iscom(varargin{1}) ...
             && isequal(varargin{1},gcbo);
catch
    result = false;
end

function result = local_isInvokeHGCallback(gui_State, varargin)

try
    fhandle = functions(gui_State.gui_Callback);
    result = ~isempty(findstr(gui_State.gui_Name,fhandle.file)) || ...
             (ischar(varargin{1}) ...
             && isequal(ishandle(varargin{2}), 1) ...
             && (~isempty(strfind(varargin{1},[get(varargin{2}, 'Tag'), '_'])) || ...
                ~isempty(strfind(varargin{1}, '_CreateFcn'))) );
catch
    result = false;
end


