首页 › 工业技术 › matlab实用程序百例2 › 第二章

第二章

matlab实用程序百例2 · 作者:佚名 · 字数:5,045 · 2026-10-09 13:13
支持中文男声 / 女声,可调语速
字号
背景
行距

'position',[270 100 60 40],...

'string','关闭',...

'callback','close');

l1=uicontrol('parent',h0,...

'style','listbox',...

'position',[10 300 80 80],...

'string','sin|cos|exp',...

'value',1,...

'max',0.5,...

'min',0);

f2=uicontrol('parent',h0,...

'style','text',...

'string','选择函数',...

'fontsize',10,...

'position',[10 380 80 20]);

r1=uicontrol('style','radio',...

'string','grid on',...

'value',0,...

'position',[10 100 60 20],...

'callback',[...

'grid on,',...

'set(r1,''value'',1);,',...

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

r2=uicontrol('style','radio',...

'string','grid off',...

'position',[10 80 60 20],...

'value',1,...

'callback',[...

'grid off,',...

'set(r2,''value'',1);,',...

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

e1=uicontrol('parent',h0,...

'style','edit',...

'string',0,...

'position',[20 210 60 20],...

'horizontalalignment','right');

e2=uicontrol('parent',h0,...

'style','edit',...

'string','3',...

'position',[20 150 60 20],...

'horizontalalignment','right');

t1=uicontrol('parent',h0,...

'style','text',...

'string','X from',...

'fontsize',10,...

'position',[20 230 60 20],...

'horizontalalignment','center');

t2=uicontrol('parent',h0,...

'style','text',...

'string','To',...

'fontsize',10,...

'position',[20 170 60 20],...

'horizontalalignment','center');

实例51:可设置函数曲线图视角的用户界面

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

'position',[198 56 408 468],...

'name','实例51');

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

'position',[0.15 0.45 0.7 0.5],...

'visible','off');

[x,y]=meshgrid;

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

z=sin./r;

f1=surf(x,y,z);

shading interp

view(-50,30)

camlight left

colormap([1 0 0])

fv=get(h0,'colormap');

ifv=fv;

p1=uicontrol('parent',h0,...

'style','pushbutton',...

'string','重置',...

'position',[280 120 50 30],...

'callback',[...

'set(s1,''value'',ifv);,',...

'set(s2,''value'',ifv);,',...

'set(s3,''value'',ifv);,',...

'set(h0,''colormap'',ifv)']);

p2=uicontrol('parent',h0,...

'style','pushbutton',...

'string','关闭',...

'position',[280 60 50 30],...

'callback','close');

s1=uicontrol('parent',h0,...

'style','slider',...

'min',0,...

'max',1,...

'value',fv,...

'position',[20 150 200 20],...

'callback',[...

's1k=get(s1,''value'');,',...

'fv=s1k;,',...

'set(h0,''colormap'',fv);']);

t1=uicontrol('parent',h0,...

'style','text',...

'string','改变红色成分',...

'position',[20 170 100 20]);

s2=uicontrol('parent',h0,...

'style','slider',...

'min',0,...

'max',1,...

'value',fv,...

'position',[20 100 200 20],...

'callback',[...

's2k=get(s2,''value'');,',...

'fv=s2k;,',...

'set(h0,''colormap'',fv);']);

t2=uicontrol('parent',h0,...

'style','text',...

'string','改变绿色成分',...

'position',[20 120 100 20]);

s3=uicontrol('parent',h0,...

'style','slider',...

'min',0,...

'max',1,...

'value',fv,...

'position',[20 50 200 20],...

'callback',[...

's3k=get(s3,''value'');,',...

'fv=s3k;,',...

'set(h0,''colormap'',fv);']);

t1=uicontrol('parent',h0,...

'style','text',...

'string','改变蓝色成分',...

'position',[20 70 100 20]);

实例52:可设置函数曲线图视角的用户界面

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

'position',[198 56 408 468],...

'name','实例52');

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

'position',[0.15 0.5 0.7 0.5],...

'visible','off');

[x,y]=meshgrid;

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

z=sin./r;

fh=surf(x,y,z);

shading interp

view([-60 30])

fv=get(h1,'view');

fv2=fv;

camlight left

sh1=uicontrol('parent',h0,...

'style','slider',...

'max',1,...

'min',-1,...

'value',fv/180,...

'position',[20 150 200 20],...

'callback',[...

'fv=90*get(sh1,''value'');,',...

'set(h1,''view'',[fv fv]),',...

'set(ed1,''string'',fv)']);

text1=uicontrol('parent',h0,...

'style','text',...

'string','方位角的变化滑标',...

'position',[20 170 200 20]);

sh2=uicontrol('parent',h0,...

'style','slider',...

'max',1,...

'min',-1,...

'value',fv/180,...

'position',[20 90 200 20],...

'callback',[...

'fv=90*get(sh2,''value'');,',...

'set(h1,''view'',[fv fv]),',...

'set(ed2,''string'',fv)']);

text2=uicontrol('parent',h0,...

'style','text',...

'string','仰角的变化滑标',...

'position',[20 110 200 20]);

ed1=uicontrol('parent',h0,...

'style','edit',...

'string',fv,...

'position',[30 30 50 20]);

text3=uicontrol('parent',h0,...

'style','text',...

'string','方位角的数值',...

'position',[20 50 80 20]);

ed2=uicontrol('parent',h0,...

'style','edit',...

'string',fv,...

'position',[150 30 50 20]);

text4=uicontrol('parent',h0,...

'style','text',...

'string','仰角的数值',...

'position',[135 50 80 20]);

pf1=uicontrol('parent',h0,...

'style','pushbutton',...

'string','重置',...

'position',[280 120 50 30],...

'callback',[...

'set(h1,''view'',fv2),',...

'set(sh1,''value'',fv2/180),',...

'set(sh2,''value'',fv2/180),',...

'set(ed1,''string'',fv2),',...

'set(ed2,''string'',fv2)']);

pf2=uicontrol('parent',h0,...

'style','pushbutton',...

'string','关闭',...

'position',[280 60 50 30],...

'callback','close');

实例53:可设置函数曲线光源的用户界面

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

'position',[198 56 408 468],...

'name','实例53');

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

'position',[0.15 0.5 0.7 0.5],...

'visible','off');

[x,y]=meshgrid;

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

z=sin./r;

fh=surf(x,y,z);

shading interp

view([-60 30])

camlight left

lightk=light('position',[0 -2 1]);

button1=uicontrol('parent',h0,...

'style','pushbutton',...

'string','设置光线',...

'position',[80 60 70 30],...

'callback',[...

'an1=inputdlg(''光线来源的X轴坐标'');,',...

'k1=str2num(an1{1});,',...

'an2=inputdlg(''光线来源的Y轴坐标'');,',...

'k2=str2num(an2{1});,',...

'an3=inputdlg(''光线来源的Z轴坐标'');,',...

'k3=str2num(an3{1});,',...

'set(lightk,''position'',[k1 k2 k3]);,',...

'set(edit1,''string'',[''['',num2str,'' '',num2str,'' '',num2str,'']'']);']);

目录 推荐给好友

书友评论 (0 条)

游客也可评论,登录后可享更多权益
还没有评论,快来抢沙发~