matlab's addpoints function stopped working, it says that I'm trying to use the script as a function
9 views (last 30 days)
Show older comments
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 Comments
Steven Lord
on 27 Feb 2020
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.
Answers (1)
Steven Lord
on 27 Feb 2020
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.
See Also
Categories
Find more on File Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!