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!