数学建模案例MATLAB实用程序百例(7)

2019-03-03 19:34

grid on huidiao=[...

'if i==1,',... 'i=0;,',... 'y=cos(x);,',...

'delete(h),',... 'set(hm,''string'',''正弦函数''),',... 'h=plot(x,y);,',... 'grid on,',... 'else if i==0,',... 'i=1;,',...

'y=sin(x);,',... 'set(hm,''string'',''余弦函数''),',... 'delete(h),',... 'h=plot(x,y);,',... 'grid on,',... 'end,',... 'end'];

hm=uicontrol(gcf,'style','pushbutton',... 'string','余弦函数',... 'callback',huidiao); i=1;

set(hm,'position',[250 20 60 20]); set(gca,'position',[0.2 0.2 0.6 0.6]) title('按钮的使用') hold on

实例34:栅格控制按钮 h0=figure('toolbar','none',...

file:///E|/Document/发展篇/M&M/竞赛篇/常用算法/matlab 实例/4.txt[2010/5/14 1:14:30]

'position',[200 150 450 250],... 'name','实例34'); x=0:0.5:2*pi; y=sin(x); plot(x,y) huidiao1=[...

'set(h_toggle2,''value'',0),',... 'grid on,',... ];

huidiao2=[...

'set(h_toggle1,''value'',0),',... 'grid off,',... ];

h_toggle1=uicontrol(gcf,'style','togglebutton',... 'string','grid on',... 'value',0,...

'position',[20 45 50 20],... 'callback',huidiao1);

h_toggle2=uicontrol(gcf,'style','togglebutton',... 'string','grid off',... 'value',0,...

'position',[20 20 50 20],... 'callback',huidiao2);

set(gca,'position',[0.2 0.2 0.6 0.6]) title('开关按钮的使用')

实例35:编辑框的使用 h0=figure('toolbar','none',...

'position',[200 150 350 250],...

file:///E|/Document/发展篇/M&M/竞赛篇/常用算法/matlab 实例/4.txt[2010/5/14 1:14:30]

'name','实例35'); f='Please input the letter'; huidiao1=[...

'g=upper(f);,',... 'set(h2_edit,''string'',g),',... ]; huidiao2=[...

'g=lower(f);,',... 'set(h2_edit,''string'',g),',... ];

h1_edit=uicontrol(gcf,'style','edit',... 'position',[100 200 100 50],... 'HorizontalAlignment','left',... 'string','Please input the letter',... 'callback','f=get(h1_edit,''string'');',... 'background','w',... 'max',5,... 'min',1); h2_edit=uicontrol(gcf,'style','edit',...

'HorizontalAlignment','left',... 'position',[100 100 100 50],... 'background','w',... 'max',5,... 'min',1); h1_button=uicontrol(gcf,'style','pushbutton',...

'string','小写变大写',... 'position',[100 45 100 20],... 'callback',huidiao1); h2_button=uicontrol(gcf,'style','pushbutton',...

file:///E|/Document/发展篇/M&M/竞赛篇/常用算法/matlab 实例/4.txt[2010/5/14 1:14:30]

'string','大写变小写',... 'position',[100 20 100 20],... 'callback',huidiao2);

实例36:弹出式菜单 h0=figure('toolbar','none',...

'position',[200 150 450 250],... 'name','实例36'); x=0:0.5:2*pi; y=sin(x); h=plot(x,y); grid on

hm=uicontrol(gcf,'style','popupmenu',... 'string',...

'sin(x)|cos(x)|sin(x)+cos(x)|exp(-sin(x))',... 'position',[250 20 50 20]); set(hm,'value',1) huidiao=[...

'v=get(hm,''value'');,',... 'switch v,',... 'case 1,',... 'delete(h),',... 'y=sin(x);,',... 'h=plot(x,y);,',... 'grid on,',... 'case 2,',... 'delete(h),',... 'y=cos(x);,',... 'h=plot(x,y);,',...

file:///E|/Document/发展篇/M&M/竞赛篇/常用算法/matlab 实例/4.txt[2010/5/14 1:14:30]

'grid on,',... 'case 3,',... 'delete(h),',... 'y=sin(x)+cos(x);,',... 'h=plot(x,y);,',... 'grid on,',... 'case 4,',... 'delete(h),',... 'y=exp(-sin(x));,',... 'h=plot(x,y);,',... 'grid on,',... 'end'];

set(hm,'callback',huidiao) set(gca,'position',[0.2 0.2 0.6 0.6]) title('弹出式菜单的使用') hold on

file:///E|/Document/发展篇/M&M/竞赛篇/常用算法/matlab 实例/4.txt[2010/5/14 1:14:30]


数学建模案例MATLAB实用程序百例(7).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:中医内科学Z 第7次

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: