필터 지우기
필터 지우기

Error when using legend or clicking on the plot

조회 수: 3 (최근 30일)
Ullas Rajvanshi
Ullas Rajvanshi 2016년 10월 26일
편집: Walter Roberson 2016년 11월 5일
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

채택된 답변

Nick Counts
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개)

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by