Matlab 版 (精华区)
发信人: zjliu (秋天的萝卜), 信区: Matlab
标 题: [转载]关税9
发信站: 哈工大紫丁香 (Thu Jun 12 21:26:58 2003)
h_fig = figure('MenuBar','none');
axes('position',[.07 .5 .86 .4],'box','on')
h_frame_1 = uicontrol(h_fig,...
'Units','normalized','Position',[ 0 0 1 0.4 ],...
'Style','frame');
h_frame_2 = uicontrol(h_fig,...
'Units','normalized','Position',[0.08 0.05 0.84 0.11 ],...
'Style','frame');
box_clbk_str = ['boxstatus = get(h_box,''value'');'...
'if boxstatus == 0;'...
' set(gca,''box'',''off'');'...
'else;'...
' set(gca,''box'',''on'');'...
'end;'...
'boxstatus = get(gca,''box'');'...
'set(h_status,''string'',' ...
'[''The box property is '' boxstatus]);'];
h_box = uicontrol(h_fig,...
'CallBack',box_clbk_str,...
'Units','normalized',...
'Position',[ 0.7 0.2 0.16 0.07 ],...
'String','Box',...
'Style','checkbox',...
'Value',[ 1 ]);
grid_clbk_str = ['gridstatus = get(h_grid,''value'');'...
'if gridstatus == 0;'...
' grid off;'...
'else;'...
' grid on;'...
'end;'...
'gridstatus = get(gca,''xgrid'');'...
'set(h_status,''string'',' ...
'[''The grid is '' gridstatus]);'];
h_grid = uicontrol(h_fig,...
'CallBack',grid_clbk_str,...
'Units','normalized','Position',[ 0.7 0.3 0.16 0.07 ],...
'String','Grid',...
'Style','checkbox');
plot_clbk_str = [...
'err_ind = 0;'...
'eval([''x = '' get(h_xdata,''string'') '';''],'...
' ''err_ind=1;'');'...
'if err_ind == 0;'...
' eval([''y = '' get(h_ydata,''string'') '';''],'...
' ''err_ind=2;'');'...
'end;'...
'if err_ind == 0;'...
' plot(x,y);'...
' boxstatus = get(h_box,''value'');'...
' if boxstatus == 0;'...
' set(gca,''box'',''off'');'...
' else;'...
' set(gca,''box'',''on'');'...
' end;'...
' gridstatus = get(h_grid,''value'');'...
' if gridstatus == 0;'...
' grid off;'...
' else;'...
' grid on;'...
' end;'...
' set(h_status,''string'',''Function Plotted'');'...
'elseif err_ind == 1;'...
' set(h_status,''string'',''Error defining x'');'...
'elseif err_ind == 2;'...
' set(h_status,''string'',''Error defining y(x)'');'...
'end'];
h_ydata = uicontrol(h_fig,...
'CallBack',plot_clbk_str,...
'Units','normalized','Position',[ 0.25 0.2 0.39 0.07 ],...
'String','(x*.1).^2',...
'Style','edit');
h_xdata = uicontrol(h_fig,...
'CallBack',plot_clbk_str,...
'Units','normalized','Position',[ 0.25 0.3 0.39 0.07 ],...
'String','-10:10',...
'Style','edit');
h_status = uicontrol(h_fig,...
'Units','normalized','Position',[ 0.1 0.07 0.8 0.07 ],...
'String','Status Window',...
'Style','text');
uicontrol(h_fig,...
'Units','normalized','Position',[ 0.08 0.3 0.15 0.07 ],...
'String','x =',...
'Style','text');
uicontrol(h_fig,...
'Units','normalized','Position',[ 0.08 0.2 0.15 0.07 ],...
'String','y(x) =',...
'Style','text');
eval(plot_clbk_str);
练习:
1 搞清楚程序运行的逻辑,它是如何工作的
2 这样的回调函数设计有什么问题?
--
╔═══════════════════╗
║★★★★★友谊第一 比赛第二★★★★★║
╚═══════════════════╝
※ 来源:.哈工大紫丁香 bbs.hit.edu.cn [FROM: 202.118.229.92]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:3.264毫秒