📄 matlab_program_2.txt
字号:
'position',[0.3 0.45 0.5 0.5],...
'visible','off');
l1=uimenu(gcf,'label','Draw figure',...
'tag','l1');
huidiao=[...
'if get(r1,''value'')==1,',...
'shading faceted,',...
'end,',...
'if get(r2,''value'')==1,',...
'shading flat,',...
'end,',...
'if get(r3,''value'')==1,',...
'shading interp,',...
'end,',...
'k=get(p1,''value'');,',...
'switch k,',...
'case 1,',...
'colormap(''cool''),',...
'case 2,',...
'colormap(''spring''),',...
'case 3,',...
'colormap(''summer''),',...
'case 4,',...
'colormap(''autumn''),',...
'case 5,',...
'colormap(''winter''),',...
'end'];
l11=uimenu('parent',l1,...
'label','Surface',...
'tag','l11',...
'callback',[...
'[x,y]=meshgrid(-8:0.5:8);,',...
'r=sqrt(x.^2+y.^2)+eps;,',...
'z=sin(r)./r;,',...
'surf(x,y,z),',...
huidiao]);
l12=uimenu('parent',l1,...
'label','Mesh',...
'tag','l12',...
'callback',[...
'mesh(peaks),',...
huidiao]);
l13=uimenu('parent',l1,...
'label','Membrane',...
'tag','l13',...
'callback',[...
'mesh(membrane),',...
huidiao]);
f1=uicontrol('parent',h0,...
'units','points',...
'listboxtop',0,...
'position',[12 6 100 101],...
'style','frame',...
'tag','f1');
r1=uicontrol('parent',h0,...
'units','points',...
'backgroundcolor',[0.753 0.753 0.753],...
'listboxtop',0,...
'position',[19.5 58.5 72.75 16.5],...
'string','shading faceted',...
'style','radiobutton',...
'tag','r1',...
'value',1,...
'callback',[...
'shading faceted,',...
'set(r1,''value'',1);,',...
'set(r2,''value'',0);,',...
'set(r3,''value'',0);']);
r2=uicontrol('parent',h0,...
'units','points',...
'backgroundcolor',[0.753 0.753 0.753],...
'listboxtop',0,...
'position',[19.5 35.25 78.75 18.75],...
'string','shading flat',...
'style','radiobutton',...
'tag','r2',...
'value',0,...
'callback',[...
'shading flat,',...
'set(r2,''value'',1);,',...
'set(r1,''value'',0);,',...
'set(r3,''value'',0);']);
r3=uicontrol('parent',h0,...
'units','points',...
'backgroundcolor',[0.753 0.753 0.753],...
'listboxtop',0,...
'position',[19.5 12.75 71.25 18.75],...
'string','shading interp',...
'style','radiobutton',...
'tag','r3',...
'value',0,...
'callback',[...
'shading interp,',...
'set(r3,''value'',1);,',...
'set(r1,''value'',0);,',...
'set(r2,''value'',0);']);
t1=uicontrol('parent',h0,...
'units','points',...
'backgroundcolor',[0.753 0.753 0.753],...
'fontsize',12,...
'listboxtop',0,...
'position',[14.25 75.75 90.75 22.5],...
'string','平滑处理',...
'style','text',...
'tag','t1');
t2=uicontrol('parent',h0,...
'units','points',...
'backgroundcolor',[0.753 0.753 0.753],...
'fontsize',12,...
'listboxtop',0,...
'position',[117 69 72.75 17.5],...
'string','设置色调',...
'style','text',...
'tag','t2');
p1=uicontrol('parent',h0,...
'units','points',...
'backgroundcolor',[0.753 0.753 0.753],...
'listboxtop',0,...
'position',[116.25 39 72.75 20.25],...
'string','Cool|Spring|Summer|Autumn|Winter',...
'style','popupmenu',...
'tag','p1',...
'value',1,...
'callback',[...
'k=get(p1,''value'');,',...
'switch k,',...
'case 1,',...
'colormap(''cool''),',...
'case 2,',...
'colormap(''spring''),',...
'case 3,',...
'colormap(''summer''),',...
'case 4,',...
'colormap(''autumn''),',...
'case 5,',...
'colormap(''winter''),',...
'end']);
b1=uicontrol('parent',h0,...
'units','points',...
'backgroundcolor',[0.753 0.753 0.753],...
'listboxtop',0,...
'position',[12 243 72.75 30.75],...
'string','关闭',...
'tag','b1',...
'callback','close');
b2=uicontrol('parent',h0,...
'units','points',...
'backgroundcolor',[0.753 0.753 0.753],...
'listboxtop',0,...
'position',[216.75 67.5 83.25 18.75],...
'string','Colorbar',...
'tag','b2',...
'callback','colorbar');
实例57:图形效果
h0=figure('toolbar','none',...
'position',[168 94.5 315 289.5],...
'name','实例57');
h1=axes('parent',h0,...
'position',[0.4 0.4 0.5 0.5],...
'visible','off');
f1=uicontrol('parent',h0,...
'style','frame',...
'position',[15 10 80 70],...
'string','dull',...
'units','points',...
'backgroundcolor',[0.753 0.753 0.753],...
'listboxtop',0,...
'tag','r1',...
'value',1,...
'callback',[...
'set(r1,''value'',1);,',...
'set(r2,''value'',0);,',...
'set(r3,''value'',0);,',...
'material dull']);
r1=uicontrol('parent',h0,...
'style','radiobutton',...
'position',[19.5 58.5 72.75 16.5],...
'string','dull',...
'units','points',...
'backgroundcolor',[0.753 0.753 0.753],...
'listboxtop',0,...
'tag','r1',...
'value',1,...
'callback',[...
'set(r1,''value'',1);,',...
'set(r2,''value'',0);,',...
'set(r3,''value'',0);,',...
'material dull']);
r2=uicontrol('parent',h0,...
'style','radiobutton',...
'position',[19.5 35.25 72.75 16.5],...
'string','metal',...
'units','points',...
'backgroundcolor',[0.753 0.753 0.753],...
'listboxtop',0,...
'tag','r2',...
'value',0,...
'callback',[...
'set(r2,''value'',1);,',...
'set(r1,''value'',0);,',...
'set(r3,''value'',0);,',...
'material metal']);
r3=uicontrol('parent',h0,...
'style','radiobutton',...
'position',[19.5 12.75 72.75 16.5],...
'string','shiny',...
'units','points',...
'backgroundcolor',[0.753 0.753 0.753],...
'listboxtop',0,...
'tag','r3',...
'value',0,...
'callback',[...
'set(r3,''value'',1);,',...
'set(r1,''value'',0);,',...
'set(r2,''value'',0);,',...
'material shiny']);
u1=uimenu('parent',h0,...
'label','绘图',...
'backgroundcolor',[0.753 0.753 0.753],...
'tag','u1',...
'callback',[...
'[x,y]=meshgrid(-8:0.5:8);,',...
'r=sqrt(x.^2+y.^2)+eps;,',...
'z=sin(r)./r;,',...
'surf(x,y,z),',...
'shading interp']);
b1=uicontrol('parent',h0,...
'style','pushbutton',...
'position',[19.5 150 60 20],...
'string','light',...
'units','points',...
'backgroundcolor',[0.753 0.753 0.753],...
'listboxtop',0,...
'tag','b1',...
'callback','camlight headlight');
b2=uicontrol('parent',h0,...
'style','pushbutton',...
'position',[19.5 100 60 20],...
'string','关闭',...
'units','points',...
'backgroundcolor',[0.753 0.753 0.753],...
'listboxtop',0,...
'tag','b2',...
'callback','close');
实例58:可控制小球运动速度的用户界面
h0=figure('toolbar','none',...
'position',[198 56 350 468],...
'name','实例58');
h1=axes('parent',h0,...
'position',[0.25 0.45 0.5 0.5],...
'visible','off');
t=0:0.1:4*pi;
x=sin(t);
y=cos(t);
plot(x,y)
axis equal
axis off
h=line('color',[1 0 0],...
'linestyle','.',...
'xdata',0,...
'ydata',1,...
'markersize',20,...
'erasemode','xor');
n=length(t);
i=1;
speed=0.01;
k=0;
b1huidiao=[...
'k=0;,',...
'while 1,',...
'set(h,''xdata'',x(i),''ydata'',y(i));,',...
'drawnow,',...
'pause(speed),',...
'i=i+1;,',...
'if i>n,',...
'i=1;,',...
'end,',...
'if k==1,',...
'break,',...
'end,',...
'end'];
b1=uicontrol('parent',h0,...
'units','points',...
'tag','b1',...
'style','pushbutton',...
'string','开始',...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[30 80 50 20],...
'callback',b1huidiao);
b2=uicontrol('parent',h0,...
'units','points',...
'tag','b2',...
'style','pushbutton',...
'string','停止',...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[100 80 50 20],...
'callback','k=1;');
b3=uicontrol('parent',h0,...
'units','points',...
'tag','b3',...
'style','pushbutton',...
'string','关闭',...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[170 80 50 20],...
'callback',[...
'k=1;,',...
'close']);
s1=uicontrol('parent',h0,...
'units','points',...
'tag','s1',...
'style','slider',...
'value',50*speed,...
'max',1,...
'min',0,...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[30 115 190 20],...
'callback',[...
'm=get(s1,''value'');,',...
'speed=m/50;']);
t1=uicontrol('parent',h0,...
'units','points',...
'tag','t1',...
'style','text',...
'fontsize',15,...
'string','小球运动速度',...
'backgroundcolor',[0.75 0.75 0.75],...
'position',[30 135 190 20]);
实例59:设置坐标轴纵横轴比
h0=figure('name','实例59');
h1=axes('parent',h0,...
'position',[0.3 0.45 0.5 0.5],...
'visible','off');
u1=uimenu('parent',h0,...
'label','绘图',...
'backgroundcolor',[0.753 0.753 0.753],...
'tag','u1',...
'callback',[...
'[x,y]=meshgrid(-8:0.5:8);,',...
'r=sqrt(x.^2+y.^2)+eps;,',...
'z=sin(r)./r;,',...
'mesh(x,y,z),',...
'shading interp,',...
'axis normal']);
f1=uicontrol('parent',h0,...
'units','points',...
'listboxtop',0,...
'position',[12 6 100 150],...
'style','frame',...
'tag','f1');
t1=uicontrol('parent',h0,...
'units','points',...
'backgroundcolor',[0.753 0.753 0.753],...
'listboxtop',0,...
'position',[19.5 130 72.75 16.5],...
'string','坐标纵横比',...
'style','text',...
'tag','t1');
r1=uicontrol('parent',h0,...
'units','points',...
'backgroundcolor',[0.753 0.753 0.753],...
'listboxtop',0,...
'position',[19.5 110 72.75 16.5],...
'string','axis equal',...
'style','radiobutton',...
'tag','r1',...
'value',1,...
'callback',[...
'set(r1,''value'',1);,',...
'set(r2,''value'',0);,',...
'set(r3,''value'',0);,',...
'set(r4,''value'',0);,',...
'set(r5,''value'',0);,',...
'axis equal']);
r2=uicontrol('parent',h0,...
'units','points',...
'backgroundcolor',[0.753 0.753 0.753],...
'listboxtop',0,...
'position',[19.5 85 72.75 16.5],...
'string','axis square',...
'style','radiobutton',...
'tag','r2',...
'value',0,...
'callback',[...
'set(r2,''value'',1);,',...
'set(r1,''value'',0);,',...
'set(r3,''value'',0);,',...
'set(r4,''value'',0);,',...
'set(r5,''value'',0);,',...
'axis square']);
r3=uicontrol('parent',h0,...
'units','points',...
'backgroundcolor',[0.753 0.753 0.753],...
'listboxtop',0,...
'position',[19.5 60 72.75 16.5],...
'string','axis image',...
'style','radiobutton',...
'tag','r3',...
'value',0,...
'callback',[...
'set(r3,''value'',1);,',...
'set(r2,''value'',0);,',...
'set(r1,''value'',0);,',...
'set(r4,''value'',0);,',...
'set(r5,''value'',0);,',...
'axis image']);
r4=uicontrol('parent',h0,...
'units','points',...
'backgroundcolor',[0.753 0.753 0.753],...
'listboxtop',0,...
'position',[19.5 35 72.75 16.5],...
'string','axie vis3d',...
'style','radiobutton',...
'tag','r4',...
'value',0,...
'callback',[...
'set(r4,''value'',1);,',...
'set(r2,''value'',0);,',...
'set(r3,''value'',0);,',...
'set(r1,''value'',0);,',...
'set(r5,''value'',0);,',...
'axis vis3d']);
r5=uicontrol('parent',h0,...
'units','points',...
'backgroundcolor',[0.753 0.753 0.753],...
'listboxtop',0,...
'position',[19.5 10 72.75 16.5],...
'string','axis auto',...
'style','radiobutton',...
'tag','r5',...
'value',0,...
'callback',[...
'set(r5,''value'',1);,',...
'set(r2,''value'',0);,',...
'set(r3,''value'',0);,',...
'set(r4,''value'',0);,',...
'set(r1,''value'',0);,',...
'axis auto']);
b1=uicontrol('parent',h0,...
'units','points',...
'backgroundcolor',[0.753 0.753 0.753],...
'listboxtop',0,...
'position',[12 243 72.75 30.75],...
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -