星期六, 1月 06, 2007

GUI-WORK


程式碼
function beework
f=figure('visible','off','position',[360,500,572,504]); % 建window
hstart=uicontrol('Style','pushbutton','String','update','Position',...
[500,400,70,50],'callback',{@updatebutton_callback});% 按鈕
hpopup=uicontrol('Style','popupmenu','String',...
{'plot(x)','pie(x)','hist(y)','ezplot3(f)','polar(theta,r)','area(x,y)'}...
,'Position',[400,400,80,25]); % 選單
htext=uicontrol('Style','text','String','Select Data','Position',[400,430,80,25]); % 說明
hax=axes('Units','pixels','Position',[50,150,300,300]); % 圖window

set([f,hax,hstart,hpopup,htext],'Units','normalized');

plot(rand(5)); % 初始圖

set(f,'Name','beework GUI')
movegui(f,'center')
set(f,'Visible','on');

function updatebutton_callback(source,eventdata)
va=get(hpopup,'value'); % call 選單值
switch va;
case 1
plot(rand(5));
case 2
n=round(10*rand)+10;
pie(2:4:n);
case 3
hist(randn(1000,1));
case 4
ezplot3('t*sin(t)', 'cos(t)', 't', [0,6*pi]);
case 5
theta = linspace(0, 2*pi);
polar(theta, 3+2*rand*cos(4*theta));
case 6
y=[1 1.2 1.5 2*rand;4 4.5 6.6 7*rand;5 6.5 8 15*rand]';
area([1980 1990 2000 2008],y);
grid on;colormap cool;
end
end
end










沒有留言:

花蓮的海豚

花蓮的海豚