matlab的一个程序,不知道什么问题。
程序如下:hfigure=figure('name','设置曲线的形状与颜色','menubar','none','numbertitle','off','visible...
程序如下:
hfigure=figure('name','设置曲线的形状与颜色','menubar','none','numbertitle','off','visible','off','position',[200 60 450 450]);
haxes=axes('position',[0.15 0.45 0.7 0.4],'xlim',[0 7],'ylim',[-1 1],'units','normalized');
t=0:0.01:2*pi;
hline=line(t,sin(t),'parent',haxes);
xlabel('自变量x');
ylabel('函数值y');
title('y=sin(x)');
set(0,'defaultuicontrolfontsize',12);
uicontrol('position',[80 40 50 30],'string','实线','callback','set(hline,"linestyle","-")');
uicontrol('position',[190 40 50 30],'string','虚线','callback','set(hline,"linestyle","--")');
uicontrol('position',[300 40 50 30],'string','无线','callback','set(hline,"linestyle","none")');
uicontrol('position',[80 80 50 30],'string','红色','callback','set(hline,"color","r")');
uicontrol('position',[190 80 50 30],'string','绿色','callback','set(hline,"color","g")');
uicontrol('position',[300 80 50 30],'string','蓝色','callback','set(hline,"color","b")');
uicontrol('position',[80 120 50 30],'string','加号','callback','set(hline,"marker","+")');
uicontrol('position',[190 120 50 30],'string','圆圈','callback','set(hline,"marker","o")');
uicontrol('position',[300 120 50 30],'string','星号','callback','set(hline,"marker","*")');
set(hfigure,'visible','on');
错误如下:
??? Error using ==> set(hline,"linestyle","--")
Error: The input character is not valid in MATLAB statements or expressions.
??? Error while evaluating uicontrol Callback
希望哪位大神能够帮忙解决 展开
hfigure=figure('name','设置曲线的形状与颜色','menubar','none','numbertitle','off','visible','off','position',[200 60 450 450]);
haxes=axes('position',[0.15 0.45 0.7 0.4],'xlim',[0 7],'ylim',[-1 1],'units','normalized');
t=0:0.01:2*pi;
hline=line(t,sin(t),'parent',haxes);
xlabel('自变量x');
ylabel('函数值y');
title('y=sin(x)');
set(0,'defaultuicontrolfontsize',12);
uicontrol('position',[80 40 50 30],'string','实线','callback','set(hline,"linestyle","-")');
uicontrol('position',[190 40 50 30],'string','虚线','callback','set(hline,"linestyle","--")');
uicontrol('position',[300 40 50 30],'string','无线','callback','set(hline,"linestyle","none")');
uicontrol('position',[80 80 50 30],'string','红色','callback','set(hline,"color","r")');
uicontrol('position',[190 80 50 30],'string','绿色','callback','set(hline,"color","g")');
uicontrol('position',[300 80 50 30],'string','蓝色','callback','set(hline,"color","b")');
uicontrol('position',[80 120 50 30],'string','加号','callback','set(hline,"marker","+")');
uicontrol('position',[190 120 50 30],'string','圆圈','callback','set(hline,"marker","o")');
uicontrol('position',[300 120 50 30],'string','星号','callback','set(hline,"marker","*")');
set(hfigure,'visible','on');
错误如下:
??? Error using ==> set(hline,"linestyle","--")
Error: The input character is not valid in MATLAB statements or expressions.
??? Error while evaluating uicontrol Callback
希望哪位大神能够帮忙解决 展开
展开全部
把所有的双引号(")替换成两个单引号('')即可。
hfigure=figure('name','设置曲线的形状与颜色','menubar','none','numbertitle','off','visible','off','position',[200 60 450 450]);
haxes=axes('position',[0.15 0.45 0.7 0.4],'xlim',[0 7],'ylim',[-1 1],'units','normalized');
t=0:0.01:2*pi;
hline=line(t,sin(t),'parent',haxes);
xlabel('自变量x');
ylabel('函数值y');
title('y=sin(x)');
set(0,'defaultuicontrolfontsize',12);
uicontrol('position',[80 40 50 30],'string','实线','callback','set(hline,''linestyle'',''-'')');
uicontrol('position',[190 40 50 30],'string','虚线','callback','set(hline,''linestyle'',''--'')');
uicontrol('position',[300 40 50 30],'string','无线','callback','set(hline,''linestyle'',''none'')');
uicontrol('position',[80 80 50 30],'string','红色','callback','set(hline,''color'',''r'')');
uicontrol('position',[190 80 50 30],'string','绿色','callback','set(hline,''color'',''g'')');
uicontrol('position',[300 80 50 30],'string','蓝色','callback','set(hline,''color'',''b'')');
uicontrol('position',[80 120 50 30],'string','加号','callback','set(hline,''marker'',''+'')');
uicontrol('position',[190 120 50 30],'string','圆圈','callback','set(hline,''marker'',''o'')');
uicontrol('position',[300 120 50 30],'string','星号','callback','set(hline,''marker'',''*'')');
set(hfigure,'visible','on');
展开全部
??? Error using ==> set(hline,"linestyle","--")
Error: The input character is not valid in MATLAB statements or expressions.
表示错误,输入的“--”这行命令的变量在matlab声明或表达里面是无效或非法的。换个线型试试
Error: The input character is not valid in MATLAB statements or expressions.
表示错误,输入的“--”这行命令的变量在matlab声明或表达里面是无效或非法的。换个线型试试
追问
所有的都是错误的,无论是线性还是其他的,点击其他控件也是错误的
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询