matlab建立快捷菜单clear;x=0:pi/100:2*pi;y=2*exp(-0.5*x).*sin(2*pi*x);h1=plot(x,y);hc=uicontextmenu;hls=uimenu(hc,'label','线型');hlw=uimenu(hc,'label','线宽');uimenu(hls,'label','虚线','call','set(h1,"LineStyle",":")'); uimenu(hls,'label'

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/17 14:24:00
matlab建立快捷菜单clear;x=0:pi/100:2*pi;y=2*exp(-0.5*x).*sin(2*pi*x);h1=plot(x,y);hc=uicontextmenu;hls=uimenu(hc,'label','线型');hlw=uimenu(hc,'label','线宽');uimenu(hls,'label','虚线','call','set(h1,
xkVaN|[3m0 -dAVdK.FOͥM& $iб҂eƒbEveF;w-))s9Qw?o;+g/ D(œD:-J2 V1JEp]tF@b49쾩M~n^JJNЗ%SU|^?`;jdh}]`O?\>~5Xa-{9yn)(!Q!#S0b>AfSlt? W4-Y{]ٳ?^8[-ԑ :h;]ZYZec5lQ[@lzqA Gi$@L bUo}~_I+i6 +6lrxxN

matlab建立快捷菜单clear;x=0:pi/100:2*pi;y=2*exp(-0.5*x).*sin(2*pi*x);h1=plot(x,y);hc=uicontextmenu;hls=uimenu(hc,'label','线型');hlw=uimenu(hc,'label','线宽');uimenu(hls,'label','虚线','call','set(h1,"LineStyle",":")'); uimenu(hls,'label'
matlab建立快捷菜单
clear;
x=0:pi/100:2*pi;
y=2*exp(-0.5*x).*sin(2*pi*x);
h1=plot(x,y);
hc=uicontextmenu;
hls=uimenu(hc,'label','线型');
hlw=uimenu(hc,'label','线宽');
uimenu(hls,'label','虚线','call','set(h1,"LineStyle",":")');
uimenu(hls,'label','实线','call','set(h1,"LineStyle","-")');
uimenu(hlw,'label','加宽','call','set(h1,"Linewidth",2)');
uimenu(hlw,'label','变细','call','set(h1,"Linewidth",0.5)');
set(h1,'uicontextmenu',hc); 为什么当我在屏幕上点切换选项是出现这个
Error using ==> set(h1,"Linewidth",2)
Error:The input character is not valid in MATLAB statements or expressions.
Error while evaluating uimenu Callback

matlab建立快捷菜单clear;x=0:pi/100:2*pi;y=2*exp(-0.5*x).*sin(2*pi*x);h1=plot(x,y);hc=uicontextmenu;hls=uimenu(hc,'label','线型');hlw=uimenu(hc,'label','线宽');uimenu(hls,'label','虚线','call','set(h1,"LineStyle",":")'); uimenu(hls,'label'
clear
screen=get(0,'ScreenSize');
W=screen(3);H=screen(4);
%定义菜单选项,绘曲线
figure('Color',[1,1,1],'Position',[0.4*H,0.4*H,0.8*W,0.6*H],'Name',...
'显示函数图形','NumberTitle','off','MenuBar','none');
hplot=uimenu(gcf,'Label','绘曲线');
ss='UIContextMenu';
uimenu(hplot,'Label','sinx/x','Call',['x=0:pi/100:2*pi;y=sin(x)./x;line=plot(x,y);set(line,ss,jhf);']);
uimenu(hplot,'Label','sinx','Call',['x=0:pi/100:2*pi;y=sin(x);line=plot(x,y);set(line,ss,jhf);']);
%定义快捷菜单,实现对图形线型颜色及属性的处理
jhf=uicontextmenu;
xx=uimenu(jhf,'Label','线型');
xk=uimenu(jhf,'Label','线宽');
ys=uimenu(jhf,'Label','颜色');
uimenu(xx,'Label','虚线','Call',['set(line,''LineStyle'','':'');']);
uimenu(xx,'Label','实线','Call',['set(line,''LineStyle'',''-'');']);
uimenu(xx,'Label','点划线','Call',['set(line,''LineStyle'',''-.'');']);
uimenu(xx,'Label','双划线','Call',['set(line,''LineStyle'',''--'');']);
uimenu(xk,'Label','宽','Call',['set(line,''LineWidth'',5);']);
uimenu(xk,'Label','窄','Call',['set(line,''LineWidth'',0.5);']);
uimenu(ys,'Label','蓝色','Call',['set(line,''Color'',''b'');']);
uimenu(ys,'Label','绿色','Call',['set(line,''Color'',''g'');']);
uimenu(ys,'Label','红色','Call',['set(line,''Color'',''r'');']);
uimenu(ys,'Label','青色','Call',['set(line,''LineColor'',''c'');']);
uimenu(ys,'Label','品红色','Call',['set(line,''Color'',''m'');']);
uimenu(ys,'Label','黄色','Call',['set(line,''Color'',''y'');']);
uimenu(ys,'Label','黑色','Call',['set(line,''Color'',''k'');']);
uimenu(ys,'Label','白色','Call',['set(line,''Color'',''w'');']);
set(line,'UIContextMenu',jhf);
%用按钮来实现标记
s='y=sinx/x y=sinx';
jhf1=uicontrol(gcf,'Style','push','Position',[20,20,100,25],'String','显示函数','Callback',['my=max(line);a=find(my);mx=(a+1)*pi/100;text(mx,my,s)']);