matlab实用程序百例之界面设计篇.docx

上传人:b****2 文档编号:24450575 上传时间:2023-05-27 格式:DOCX 页数:105 大小:29.23KB
下载 相关 举报
matlab实用程序百例之界面设计篇.docx_第1页
第1页 / 共105页
matlab实用程序百例之界面设计篇.docx_第2页
第2页 / 共105页
matlab实用程序百例之界面设计篇.docx_第3页
第3页 / 共105页
matlab实用程序百例之界面设计篇.docx_第4页
第4页 / 共105页
matlab实用程序百例之界面设计篇.docx_第5页
第5页 / 共105页
点击查看更多>>
下载资源
资源描述

matlab实用程序百例之界面设计篇.docx

《matlab实用程序百例之界面设计篇.docx》由会员分享,可在线阅读,更多相关《matlab实用程序百例之界面设计篇.docx(105页珍藏版)》请在冰豆网上搜索。

matlab实用程序百例之界面设计篇.docx

matlab实用程序百例之界面设计篇

1-32是:

图形应用篇

33-66是:

界面设计篇

67-84是:

图形处理篇

85-100是:

数值分析篇

实例33:

曲线转换按钮

h0=figure('toolbar','none',...

'position',[200150450250],...

'name','实例33');

x=0:

0.5:

2*pi;

y=sin(x);

h=plot(x,y);

gridon

huidiao=[...

'ifi==1,',...

'i=0;,',...

'y=cos(x);,',...

'delete(h),',...

'set(hm,''string'',''正弦函数''),',...

'h=plot(x,y);,',...

'gridon,',...

'elseifi==0,',...

'i=1;,',...

'y=sin(x);,',...

'set(hm,''string'',''余弦函数''),',...

'delete(h),',...

'h=plot(x,y);,',...

'gridon,',...

'end,',...

'end'];

hm=uicontrol(gcf,'style','pushbutton',...

'string','余弦函数',...

'callback',huidiao);

i=1;

set(hm,'position',[250206020]);

set(gca,'position',[0.20.20.60.6])

title('按钮的使用')

holdon

实例34:

栅格控制按钮

h0=figure('toolbar','none',...

'position',[200150450250],...

'name','实例34');

x=0:

0.5:

2*pi;

y=sin(x);

plot(x,y)

huidiao1=[...

'set(h_toggle2,''value'',0),',...

'gridon,',...

];

huidiao2=[...

'set(h_toggle1,''value'',0),',...

'gridoff,',...

];

h_toggle1=uicontrol(gcf,'style','togglebutton',...

'string','gridon',...

'value',0,...

'position',[20455020],...

'callback',huidiao1);

h_toggle2=uicontrol(gcf,'style','togglebutton',...

'string','gridoff',...

'value',0,...

'position',[20205020],...

'callback',huidiao2);

set(gca,'position',[0.20.20.60.6])

title('开关按钮的使用')

实例35:

编辑框的使用

h0=figure('toolbar','none',...

'position',[200150350250],...

'name','实例35');

f='Pleaseinputtheletter';

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',[10020010050],...

'HorizontalAlignment','left',...

'string','Pleaseinputtheletter',...

'callback','f=get(h1_edit,''string'');',...

'background','w',...

'max',5,...

'min',1);

h2_edit=uicontrol(gcf,'style','edit',...

'HorizontalAlignment','left',...

'position',[10010010050],...

'background','w',...

'max',5,...

'min',1);

h1_button=uicontrol(gcf,'style','pushbutton',...

'string','小写变大写',...

'position',[1004510020],...

'callback',huidiao1);

h2_button=uicontrol(gcf,'style','pushbutton',...

'string','大写变小写',...

'position',[1002010020],...

'callback',huidiao2);

实例36:

弹出式菜单

h0=figure('toolbar','none',...

'position',[200150450250],...

'name','实例36');

x=0:

0.5:

2*pi;

y=sin(x);

h=plot(x,y);

gridon

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

'string',...

'sin(x)|cos(x)|sin(x)+cos(x)|exp(-sin(x))',...

'position',[250205020]);

set(hm,'value',1)

huidiao=[...

'v=get(hm,''value'');,',...

'switchv,',...

'case1,',...

'delete(h),',...

'y=sin(x);,',...

'h=plot(x,y);,',...

'gridon,',...

'case2,',...

'delete(h),',...

'y=cos(x);,',...

'h=plot(x,y);,',...

'gridon,',...

'case3,',...

'delete(h),',...

'y=sin(x)+cos(x);,',...

'h=plot(x,y);,',...

'gridon,',...

'case4,',...

'delete(h),',...

'y=exp(-sin(x));,',...

'h=plot(x,y);,',...

'gridon,',...

'end'];

set(hm,'callback',huidiao)

set(gca,'position',[0.20.20.60.6])

title('弹出式菜单的使用')

实例37:

滑标的使用

h0=figure('toolbar','none',...

'position',[200150450250],...

'name','实例37');

[x,y]=meshgrid(-8:

0.5:

8);

r=sqrt(x.^2+y.^2)+eps;

z=sin(r)./r;

h0=mesh(x,y,z);

h1=axes('position',...

[0.20.20.50.5],...

'visible','off');

htext=uicontrol(gcf,...

'units','points',...

'position',[20304515],...

'string','brightness',...

'style','text');

hslider=uicontrol(gcf,...

'units','points',...

'position',[101030015],...

'min',-1,...

'max',1,...

'style','slider',...

'callback',...

'brighten(get(hslider,''value''))');

实例38:

多选菜单

h0=figure('toolbar','none',...

'position',[200150450250],...

'name','实例38');

[x,y]=meshgrid(-8:

0.5:

8);

r=sqrt(x.^2+y.^2)+eps;

z=sin(r)./r;

h0=mesh(x,y,z);

hlist=uicontrol(gcf,'style','listbox',...

'string','default|spring|summer|autumn|winter',...

'max',5,...

'min',1,...

'position',[202080100],...

'callback',[...

'k=get(hlist,''value'');,',...

'switchk,',...

'case1,',...

'colormapdefault,',...

'case2,',...

'colormapspring,',...

'case3,',...

'colormapsummer,',...

'case4,',...

'colormapautumn,',...

'case5,',...

'colormapwinter,',...

'end']);

实例39:

菜单控制的使用

h0=figure('toolbar','none',...

'position',[200150450250],...

'name','实例39');

x=0:

0.5:

2*pi;

y=cos(x);

h=plot(x,y);

gridon

set(gcf,'toolbar','none')

hm=uimenu('label','example');

huidiao1=[...

'set(hm_gridon,''checked'',''on''),',...

'set(hm_gridoff,''checked'',''off''),',...

'gridon'];

huidiao2=[...

'set(hm_gridoff,''checked'',''on''),',...

'set(hm_gridon,''checked'',''off''),',...

'gridoff'];

hm_gridon=uimenu(hm,'label','gridon',...

'checked','on',...

'callback',huidiao1);

hm_gridoff=uimenu(hm,'label','gridoff',...

'checked','off',...

'callback',huidiao2);

实例40:

UIMENU菜单的应用

h0=figure('toolbar','none',...

'position',[200150450250],...

'name','实例40');

h1=uimenu(gcf,'label','函数');

h11=uimenu(h1,'label','轮廓图',...

'callback',[...

'set(h31,''checked'',''on''),',...

'set(h32,''checked'',''off''),',...

'[x,y,z]=peaks;,',...

'contour3(x,y,z,30)']);

h12=uimenu(h1,'label','高斯分布',...

'callback',[...

'set(h31,''checked'',''on''),',...

'set(h32,''checked'',''off''),',...

'mesh(peaks);,',...

'axistight']);

h13=uimenu(h1,'label','Sinc函数',...

'callback',[...

'set(h31,''checked'',''on''),',...

'set(h32,''checked'',''off''),',...

'[x,y]=meshgrid(-8:

0.5:

8);,',...

'r=sqrt(x.^2+y.^2)+eps;,',...

'z=sin(r)./r;,',...

'mesh(x,y,z)']);

h2=uimenu(gcf,'label','色彩');

hl2

(1)=uimenu(h2,'label','Default',...

'checked','on',...

'callback',...

[...

'set(hl2,''checked'',''off''),',...

'set(hl2

(1),''checked'',''on''),',...

'colormap(''default'')']);

hl2

(2)=uimenu(h2,'label','spring',...

'callback',...

[...

'set(hl2,''checked'',''off''),',...

'set(hl2

(2),''checked'',''on''),',...

'colormap(spring)']);

hl2(3)=uimenu(h2,'label','Summer',...

'callback',...

[...

'set(hl2,''checked'',''off''),',...

'set(hl2(3),''checked'',''on''),',...

'colormap(summer)']);

hl2(4)=uimenu(h2,'label','Autumn',...

'callback',...

[...

'set(hl2,''checked'',''off''),',...

'set(hl2(4),''checked'',''on''),',...

'colormap(autumn)']);

hl2(5)=uimenu(h2,'label','Winter',...

'callback',...

[...

'set(hl2,''checked'',''off''),',...

'set(hl2(5),''checked'',''on''),',...

'colormap(winter)']);

h3=uimenu(gcf,'label','坐标选项');

h31=uimenu(h3,'label','Axison',...

'callback',...

[...

'axison,',...

'set(h31,''checked'',''on''),',...

'set(h32,''checked'',''off'')']);

h32=uimenu(h3,'label','Axisoff',...

'callback',...

[...

'axisoff,',...

'set(h32,''checked'',''on''),',...

'set(h31,''checked'',''off'')']);

实例41:

除法计算器

h=figure('toolbar','none',...

'position',[200150450250],...

'name','实例41');

h1=uicontrol(gcf,'style','edit',...

'position',[8020010020],...

'HorizontalAlignment','right',...

'callback',['m=get(h1,''string'');,',...

'a=str2num(m);']);

h2=uicontrol(gcf,'style','edit',...

'HorizontalAlignment','right',...

'position',[8015010020],...

'callback',['n=get(h2,''string'');,',...

'b=str2num(n);']);

h3=uicontrol(gcf,'style','text',...

'string','被除数',...

'position',[8023010020]);

h4=uicontrol(gcf,'style','edit',...

'position',[805010020]);

h5=uicontrol(gcf,'style','pushbutton',...

'position',[8010010020],...

'string','=',...

'callback',[...

'ifb==0,',...

'h7=errordlg(''除数不能为0!

'',''error'',''on'');,',...

'else,',...

'k=a/b;,',...

'c=num2str(k);,',...

'set(h4,''string'',c),',...

'end']);

h8=uicontrol(gcf,'style','text',...

'string','除数',...

'position',[8017510020]);

h9=uicontrol(gcf,'style','text',...

'string','商',...

'position',[807510020]);

实例42:

单选框的使用

h0=figure('toolbar','none',...

'position',[200150450250],...

'name','实例42');

x=0:

0.5:

2*pi;

y=sin(x);

plot(x,y)

gridon

set(gcf,'toolbar','none')

g=set(gca,'position',[0.20.20.60.6]);

huidiao1=[...

'gridon,',...

'set(box_on,''value'',1),',...

'set(box_off,''value'',0),'];

huidiao2=[...

'gridoff,',...

'set(box_off,''value'',1),',...

'set(box_on,''value'',0),'];

box_on=uicontrol(gcf,'style','radio',...

'position',[5505020],...

'string','gridon',...

'value',1,...

'callback',huidiao1);

box_off=uicontrol(gcf,'style','radio',...

'position',[5205020],...

'string','gridoff',...

'value',0,...

'callback',huidiao2);

title('无线按钮的使用')

实例43:

添加环境效果

h0=figure('toolbar','none',...

'position',[19856450468],...

'name','实例43');

h1=axes('parent',h0,...

'position',[0.150.450.70.5],...

'visible','off');

sphere

h=findobj('type','surface');

shadinginterp

axisequal

l=light('position',[0-21]);

k

(1)=get(h,'specularstrength');

k

(2)=get(h,'diffusestrength');

k(3)=get(h,'specularexponent');

k(4)=get(h,'specularcolorreflectance');

u1=uimenu('parent',h0,...

'label','灯光效果',...

'tag','u1',...

'backgroundcolor',[0.750.750.75]);

u11=uimenu('parent',u1,...

'label','gouraud',...

'tag','u11',...

'backgroundcolor',[0.750.750.75],...

'callback',[...

'set(u11,''checked'',''on'');,',...

'set(u12,''checked'',''off'');,',...

'set(h,''facelighting'',''gouraud'')']);

u12=uimenu('parent',u1,...

'label','phong',...

'tag','u12',...

'backgroundcolor',[0.750.750.75],...

'callback',[...

'set(u11,''checked'',''off'');,',...

'set(u12,''checked'',''on'');,',...

'set(h,''facelighting'',''gouraud'')']);

u2=uimenu('parent',h0,...

'label','背面灯光',...

'tag','u2',...

'backgroundcolor',[0.750.750.75]);

u21=uimenu('parent',u2,...

'label','reverselit',...

'tag','u21',...

'checked','on',...

'backgroundcolor',[0.750.750.75],...

'callback',[...

'set(u21,''checked'',''on'');,',...

'set(u22,''checked'',''off'');,',..

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 求职职场 > 面试

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1