function threeplt2()
f = figure('Visible','off','Position',[0,0,800,600]);
bw = .02 * [1 1 -2 -2];
handle = uipanel('Units','Normalized','Position',[0 .8 1 .2] + bw);
uicontrol('Parent',handle,'Style','pushbutton','Units','Normalized','String','f = ','Position',[0 0 1/12 1]);
eh = uicontrol('Parent',handle,'Style','edit','Units','Normalized','String','x','Position',[1/12 0 2/12 1],'Callback',@draw3d);


uicontrol('Parent',handle,'Style','pushbutton','Units','Normalized','String','a = ','Position',[3/12 0 1/12 1]);
ah = uicontrol('Parent',handle,'Style','edit','Units','Normalized','String','0','Position',[4/12 0 1/12 1],'Callback',@draw3d);
uicontrol('Parent',handle,'Style','pushbutton','Units','Normalized','String','b = ','Position',[5/12 0 1/12 1]);
bh = uicontrol('Parent',handle,'Style','edit','Units','Normalized','String','2','Position',[6/12 0 1/12 1],'Callback',@draw3d);
uicontrol('Parent',handle,'Style','pushbutton','Units','Normalized','String','c = ','Position',[7/12 0 1/12 1]);
ch = uicontrol('Parent',handle,'Style','edit','Units','Normalized','String','0','Position',[8/12 0 1/12 1],'Callback',@draw3d);
uicontrol('Parent',handle,'Style','pushbutton','Units','Normalized','String','d = ','Position',[9/12 0 1/12 1]);
dh = uicontrol('Parent',handle,'Style','edit','Units','Normalized','String','2','Position',[10/12 0 1/12 1],'Callback',@draw3d);

%uicontrol('Parent',handle,'Style','pushbutton','Units','Normalized','String','n = ','Position',[10/12 0 1/10 1]);
%nh = uicontrol('Parent',handle,'Style','edit','Units','Normalized','String','50','Position',[11/12 0 1/10 1],'Callback',@draw3d);
nh=20;
sl=uicontrol('Parent',f,'Style','slider','Min', 10, 'Max',100,'SliderStep',[.05,.05],'Value',20,'Units','normalized','Position',[0 0 1 1/20],'Callback',@draw3d);
subplot('Position',[1/20,2/20 .9 .7])

draw3d();
set(f,'Visible','on');


function draw3d(source,eventdata)
 
fstr = regexprep(['@(x,y)' get(eh,'String')],{'*','/','\^'},{'.*','./','.\^'});
fh = eval(fstr);
N=50;
a = str2num(get(ah,'String'));
b = str2num(get(bh,'String'));
c = str2num(get(ch,'String'));
d = str2num(get(dh,'String'));

N=round(get(sl,'Value'));
x=linspace(a,b,N);
y=linspace(c,d,N);

[X,Y]=meshgrid(x,y);
z=feval(fh,X,Y);
mesh(X,Y,z)
end

   

end