麻烦哪位大神把下面的MATLAB 代码 每句给我注释一下,谢谢

2024-12-18 18:32:29
推荐回答(1个)
回答1:

h0=figure('toolbar','none',... %新的figure,关闭菜单栏
'position',[200 150 450 250],...%显示位置
'name','菜单');%标题名
h1=uimenu(gcf,'label','函数');%在当前figure建立新的菜单
h11=uimenu(h1,'label','轮廓图',...%在h1下再创立菜单
'callback',[... %回调函数
'set(h31,''checked'',''on''),',...
'set(h32,''checked'',''off''),',...
'[x,y,z]=peaks;,',...
'contour3(x,y,z,30)']);
h12=uimenu(h1,'label','高斯分布',...%同h11
'callback',[...
'set(h31,''checked'',''on''),',...
'set(h32,''checked'',''off''),',...
'mesh(peaks);,',...
'axis tight']);
h13=uimenu(h1,'label','Sinc函数',...%同h13
'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','色彩');%figure下新的菜单
%下面是基本差不都的功能实现。不明白的话,可以设一个断点,慢慢看程序执行过程
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','Axis on',...
'callback',...
[...
'axis on,',...
'set(h31,''checked'',''on''),',...
'set(h32,''checked'',''off'')']);
h32=uimenu(h3,'label','Axis off',...
'callback',...
[...
'axis off,',...
'set(h32,''checked'',''on''),',...
'set(h31,''checked'',''off'')']);