I recently had to program a simple GUI that controls some plots. I don't know exactly what your task is, but here's some basic code to get you started. This creates two figures; Figure 1 has controls, Figure 2 has a plot of y=x^p. You enter the value of p into the box and press enter to register it and replot; then press the button to reset to default p=1.
function SampleGUI()
x=linspace(-2,2,100);
power=1;
y=x.^power;
ctrl_fh = figure; % controls figure handle
plot_fh = figure; % plot figure handle
plot(x,y);
% uicontrol handles:
hPwr = uicontrol('Style','edit','Parent',...
ctrl_fh,...
'Position',[45 100 100 20],...
'String',num2str(power),...
'CallBack',@pwrHandler);
hButton = uicontrol('Style','pushbutton','Parent',ctrl_fh,...
'Position',[45 150 100 20],...
'String','Reset','Callback',@reset);
function reset(source,event,handles,varargin) % boilerplate argument string
fprintf('resetting...\n');
power=1;
set(hPwr,'String',num2str(power));
y=x.^power;
compute_and_draw_plot();
end
function pwrHandler(source,event,handles,varargin)
power=str2num(get(hPwr,'string'));
fprintf('Setting power to %s\n',get(hPwr,'string'));
compute_and_draw_plot();
end
function compute_and_draw_plot()
y=x.^power;
figure(plot_fh); plot(x,y);
end
end
The basic idea behind GUIs is that when you manipulate controls they call "Callback" functions, i.e. event handlers; these functions are able to interact through controls using the control handles and set/get methods to obtain or change their properties.
To get to the list of available properties, peruse the very informative Handle Graphics Property Browser on Matlab's documentation website (http://www.mathworks.com/access/helpdesk/help/techdoc/infotool/hgprop/doc_frame.html); click on UI Objects (or whatever else that you need).
Hope this helps!