Error when using legend or clicking on the plot
1 次查看(过去 30 天)
显示 更早的评论
Hi. I am a student whos studying MatLab basics. Am using a MacBook, and when I use the legend function while plotting it always gives me an error and am not able to get the legend. The error looks like this:
Attempt to execute SCRIPT allchild as a function:
/Users/ullasrajvanshi/Documents/MATLAB/allchild.m
Error in get_legendable_children (line 9)
legkids = allchild(ax);
Error in graph2dhelper (line 31)
[varargout{1:nargout}] = feval(varargin{:});
Error in legend>getLegendableChildren (line 620)
children = graph2dhelper('get_legendable_children', ha);
Error in legend>set_children_and_strings (line 632)
ch = getLegendableChildren(ha);
Error in legend>make_legend (line 334)
set_children_and_strings(ha,leg,children,strings);
Error in legend (line 282)
make_legend(ha,args(arg:end),version);
Also when I select any point on a figure, it also gives me an error. I have tried reinstalling MatLab but it doesnt work. Can anyone please help me
Thanks
0 个评论
采纳的回答
Nick Counts
2016-11-5
It looks like you have overloaded allchild.m
Enter "which allchild.m" in the command window. You should see something like this:
>> which allchild.m
/Applications/MATLAB_R2014b.app/toolbox/matlab/uitools/allchild.m
Based on your above, I predict you will get
/Users/ullasrajvanshi/Documents/MATLAB/allchild.m
Which means that you have defined a script and named it allchild.m
Now when Matlab trys to use its built-in function allchild() it is finding your script instead and things are breaking. You can rename your file or move it to a folder that isn't on the Matlab path and your issue should go away.
Good luck
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Legend 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!