matlab's addpoints function stopped working, it says that I'm trying to use the script as a function
조회 수: 8 (최근 30일)
이전 댓글 표시
Hello,
I'm just trying to add points to an animated line like this:
f=figure('Visible','on','units','normalized','outerposition',[0 0 1 1],'Numbertitle','off','Name','test');
for i=1:2
S(i)=subplot(2,1,i,'Parent',f);
h(i)=animatedline(S(i),'color','b','marker','.');
end
i=1;x=[1 2];
for j=1:numel(h)
addpoints(h(j),i,x(j));
end
But I get this error:
Attempt to execute SCRIPT addpoints as a function:
/usr/local/MATLAB/R2019b/toolbox/matlab/graphics/addpoints.m
Note that last time I used it it worked just fine...
BTW, I'm using matlab r2019b under ubuntu 18.04.
I went to matlab's install directory and `find . -type f -name "addpoints.m"` give me this:
./mcr/toolbox/matlab/graphics/addpoints.m
./toolbox/distcomp/array/+parallel/+internal/+array/@PlottableUsingGather/addpoints.m
./toolbox/matlab/graphics/addpoints.m
Of those 3, only the last one isn't empty and it just a help file, no function there...
댓글 수: 6
Steven Lord
2020년 2월 27일
Adam Danz: toolbox/distcomp contains files for Parallel Computing Toolbox. That toolbox was originally called Distributed Computing Toolbox but it was renamed several years ago. So that's okay.
In addition, it is in a folder whose name starts with the @ symbol. That makes that folder a MATLAB class folder and makes that file a method of that class. Classes defined in classdef files aren't required to be in a directory whose name starts with the @ symbol (unless they want to implement one or more methods in a separate file rather than inside the classdef file) but they are allowed to be. Older classes are required to be in a directory whose name starts with the @ symbol. So
./toolbox/distcomp/array/+parallel/+internal/+array/@PlottableUsingGather/addpoints.m
is the addpoints method for the parallel.internal.array.PlottableUsingGather class that is part of Parallel Computing Toolbox. [Since it is in an internal package, we don't recommend you use it directly.] It's only going to be called if one of the inputs is a parallel.internal.array.PlottableUsingGather object. But that might be a problem for a different reason than you think. I'll elaborate in an answer.
답변 (1개)
Steven Lord
2020년 2월 27일
What is the MATLAB root directory for your installation? You can find this using the command:
matlabroot
Are you certain that your current directory is not under matlabroot for a different installation of MATLAB, perhaps an older one?
I have Parallel Computing Toolbox installed in release R2019b (albeit on Windows) and I do not have a distcomp subdirectory under matlabroot\toolbox. According to the Release Notes for release R2019b the folder containing Parallel Computing Toolbox functionality was renamed so you shouldn't have toolbox/distcomp unless you added an older version of that directory to your MATLAB path or copied it over from an older installation (which will not work.)
So I'm wondering if your MATLAB path and/or your installation are in a bad state. To try to reset the MATLAB path back to its factory-installed state you could use the restoredefaultpath function. If you copied files or directories into your installation cleaning up the problem may be more involved.
참고 항목
카테고리
Help Center 및 File Exchange에서 File Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!