MATLAB中legend总是出错,即使如下面的小程序都出错,请大神们帮忙解决一下,万分感谢。

小程序如下x=-pi:pi/20:pi;plot(x,cos(x),'-ro',x,sin(x),'-.b')h=legend('cos_x','sin_x',2);出错... 小程序如下
x = -pi:pi/20:pi;
plot(x,cos(x),'-ro',x,sin(x),'-.b')
h = legend('cos_x','sin_x',2);
出错问题是
Attempt to call constructor text with incorrect letter case.

Error in scribe.legend/methods>strsize (line 979)
t=text('Parent',ax,...

Error in scribe.legend/methods>getsizeinfo (line 632)
strsizes(k,:) = strsize(h,ppos,fname,fsize,fangl,fwght,interp,str);

Error in scribe.legend/methods (line 19)
[varargout{1:nargout}] = feval(args{:});

Error in scribe.legend/methods>create_legend_items (line 1426)
s = methods(h,'getsizeinfo');

Error in scribe.legend/methods (line 17)
feval(args{:});

Error in scribe.legend (line 115)
methods(h,'create_legend_items',children);

Error in legend>make_legend (line 377)
lh=scribe.legend(ha,orient,location,position,children,listen,strings,propargs{:});

Error in legend (line 280)
[h,msg] = make_legend(ha,varargin(arg:end));
图像能显示,但是就是不显示图例。如果不加图例能正常运行,就是加了图例不行。
展开
 我来答
我行我素850915
2017-04-25 · TA获得超过8241个赞
知道大有可为答主
回答量:5788
采纳率:77%
帮助的人:1681万
展开全部
主要是图例的位置参数有错,程序可改为:
x = -pi:pi/20:pi;
plot(x,cos(x),'-ro',x,sin(x),'-.b')
h = legend('cos x','sin x','Location','NW');
追问
大神,你能在帮我看看这个么,图例还是显示不出来
one_H_H_1=xlsread('p1_H_H_scan1.xls');
one_H_H_1=sortrows(one_H_H_1,1);
figure(1);
plot(one_H_H_1(:,1),one_H_H_1(:,2),'r-')
a=legend('the polarization of vertical direction',-1);
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式