You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
Attempt to execute SCRIPT scatter as a function: F:\MATLAB\R2019a\toolbox\m
2 views (last 30 days)
Show older comments
Hello all,
I keep getting this error message below
Attempt to execute SCRIPT scatter as a function:
F:\MATLAB\R2019a\toolbox\matlab\specgraph\scatter.m
Note: I have checked the "specgraph" folder and delete the "scatter.m" file, but i keep getting the above error message.
Please is there any other means to handle this issue? Thank you
Accepted Answer
Cris LaPierre
on 22 Jan 2022
14 Comments
Cris LaPierre
on 22 Jan 2022
This file F:\MATLAB\R2019a\toolbox\matlab\specgraph\scatter.m is MATLAB's function for creating scatter plots. It should be a function, not a script, and you probably shouldn't be modifying it.
Please share the complete error message (all the red text)
CHARLES ADDEY
on 22 Jan 2022
Edited: Cris LaPierre
on 22 Jan 2022
I was trying to do this when i got the error
% dummy data
n = 50;
x = linspace(112,120,n)+0.25*rand(1,n); % Longitude
y = linspace(22,24,n)+0.5*rand(1,n); % Latitude
z = 10+y; % temperature
figure(1),
scatter(x,y,z,z,'filled');
colormap('jet');
colorbar('vert');
The error from the red text is the four lines below
Attempt to execute SCRIPT scatter as a function:
F:\MATLAB\R2019a\toolbox\matlab\specgraph\scatter.m
Error in Gridd_and_average (line 11)
scatter(x,y,z,z,'filled');
Cris LaPierre
on 22 Jan 2022
Pleaes run the script. If you still get the error, share the result of the following code.
pwd
which scatter -all
type scatter.m
CHARLES ADDEY
on 23 Jan 2022
Here is the result
>> pwd
which scatter -all
type scatter.m
ans =
'C:\Users\hp\Desktop\DESKTOP DOCUMENTS\INTERPOLATION AND GRIDDING(MATLAB)\interp'
F:\MATLAB\R2019a\toolbox\coder\half\@half\scatter.p % half method
function varargout =scatter(varargin)
%SCATTER Create scatter or bubble plot
% Refer to the MATLAB SCATTER reference page for more information.
%
% See also SCATTER
% Thomas A. Bryan, 2 November 2004
% Copyright 1999-2012 The MathWorks, Inc.
c = todoublecell(varargin{:});
[varargout{1:nargout}] = feval(mfilename,c{:});
>>
Cris LaPierre
on 23 Jan 2022
Have you recovered the file you deleted?
- F:\MATLAB\R2019a\toolbox\matlab\specgraph\scatter.m
CHARLES ADDEY
on 25 Jan 2022
Yes, I have recovered it, i still get the error message
Undefined function 'scatter' for input arguments of type 'double'.
Error in Gridd_and_average (line 11)
scatter(x,y,z,z,'filled');
Cris LaPierre
on 25 Jan 2022
Edited: Cris LaPierre
on 29 Jan 2022
Somewhere you have a script named scatter.m that is being called instead of the plotting function scatter. Perhaps the script you are working in? If so, try renaming your script.
If the file is restored, repeat the last 2 commands above and share the result.
CHARLES ADDEY
on 29 Jan 2022
Hi Chris, the result of the last command is shared below.
ERROR MESSAGE
>> Undefined function 'throwIfGraphics' for input arguments of type 'string'.
Error in scatter (line 31)
throwIfGraphics(x, "Line");
Error in Gridd_and_average (line 11)
scatter(x,y,z,z, 'filled');
RESULT OF LAST 2 COMMANDS
>> pwd
which scatter -all
type scatter.m
ans =
'C:\Users\hp\Desktop\DESKTOP DOCUMENTS\INTERPOLATION AND GRIDDING(MATLAB)\interp'
F:\MATLAB\R2019a\toolbox\matlab\specgraph\scatter.m
F:\MATLAB\R2019a\toolbox\coder\half\@half\scatter.p % half method
function h = scatter(varargin)
%SCATTER Scatter plot.
% Supported syntaxes for tall X, Y:
% SCATTER(X,Y)
% SCATTER(X,Y,S)
% SCATTER(X,Y,S,C)
% SCATTER(...,M)
% SCATTER(...,'filled')
% SCATTER(AX,...)
%
% Notes and Limitations:
% 1) S must be scalar or empty
% 2) C must be scalar or RGB triplet
% 3) Categorical inputs are not supported.
% 4) With tall inputs, SCATTER plots in iterations, progressively
% adding to the plot as more data is read. During updating, a progress
% indicator shows the proportion of data that has been plotted. Zooming
% and panning is supported during updating before the plot is complete.
% To pause the update process, press the pause button in the progress
% indicator.
%
% See also SCATTER, BINSCATTER, TALL, TALL/PLOT.
% Copyright 2017-2018 MathWorks, Inc.
[cax,args] = axescheck(varargin{:});
narginchk(2,inf);
x = args{1};
y = args{2};
args(1:2) = [];
throwIfGraphics(x, "Line");
% error checking in the first two inputs
tall.checkIsTall(mfilename, 1, x);
x = tall.validateType(x,mfilename,{'numeric','logical','datetime','duration'},1);
x = lazyValidate(x, {@(x1)iscolumn(x1) && (~isnumeric(x1) || isreal(x1)), ...
'MATLAB:scatter:InvalidTallData'});
tall.checkIsTall(mfilename, 2, y);
y = tall.validateType(y,mfilename,{'numeric','logical','datetime','duration'},2);
y = lazyValidate(y, {@(y1)iscolumn(y1) && (~isnumeric(y1) || isreal(y1)), ...
'MATLAB:scatter:InvalidTallData'});
[x, y] = validateSameTallSize(x,y);
% error checking for the rest of the inputs
[args, appendautofacecolor] = parseinput(args);
cax = newplot(cax);
xclass = tall.getClass(x);
yclass = tall.getClass(y);
switch xclass
case 'datetime'
xtype = datetime;
case 'duration'
xtype = duration;
otherwise % numeric, logical
xtype = 1;
end
switch yclass
case 'datetime'
ytype = datetime;
case 'duration'
ytype = duration;
otherwise % numeric, logical
ytype = 1;
end
matlab.graphics.internal.configureAxes(cax,xtype,ytype);
[~,autocolor] = matlab.graphics.chart.internal.nextstyle(cax,true,false,false);
args = [{'CData',autocolor} args];
if appendautofacecolor
args = [args {'MarkerFaceColor','flat'}];
end
t = table(x, y);
markforreuse(t);
x = subsref(t, substruct('.','x'));
y = subsref(t, substruct('.','y'));
htemp = matlab.graphics.chart.primitive.tall.Scatter('XData', x, 'YData', y, ...
args{:}, 'Parent', cax);
if nargout > 0
h = htemp;
end
function [outargs,appendautofacecolor] = parseinput(args)
tall.checkNotTall(mfilename, 2, args{:});
outargs = {};
customcolor = false;
nameoffset = 2;
ind = 1; % parsing index
if ~isempty(args) && ~isNonTallScalarString(args{ind})
% size input
s = args{ind};
if ~isempty(s)
validateattributes(s, {'numeric'}, {'scalar', 'real', 'positive', 'finite'},...
mfilename, 'Size');
outargs = {'SizeData', s};
end
ind = ind + 1;
% color input
if ind <= length(args)
if isnumeric(args{ind})
c = args{ind};
validateattributes(c,{'numeric'},{'size',[1 3],'nonnegative',...
'real', '<=', 1}, mfilename, 'Marker Color');
customcolor = true;
else
[~,c,~,tmsg] = colstyle(args{ind});
customcolor = isempty(tmsg) && ~isempty(c);
end
if customcolor
outargs = [outargs {'MarkerEdgeColor',c}];
ind = ind + 1;
end
end
end
% filled option and marker style
appendautofacecolor = false;
if ind <= length(args)
% filled option
filled = false;
if strncmpi(args{ind}, 'filled', length(args{ind}))
filled = true;
ind = ind + 1;
end
% marker style
if ind <= length(args)
[~,~,m,tmsg] = colstyle(args{ind});
if isempty(tmsg) && ~isempty(m)
outargs = [outargs {'Marker',m}];
ind = ind + 1;
end
% filled option again, such that marker style and filled are order
% independent
if ind <= length(args) && ~filled && strncmpi(args{ind}, 'filled', length(args{ind}))
filled = true;
ind = ind + 1;
end
end
if filled
if customcolor
outargs = [outargs {'MarkerFaceColor',c}];
else
appendautofacecolor = true;
end
end
end
% remaining must be name-value pairs
if rem(length(args)-ind+1,2) ~= 0
error(message('MATLAB:scatter:ArgNameValueMismatch'));
end
names = setdiff(properties('matlab.graphics.chart.primitive.tall.Scatter'),...
{'Annotation', 'BeingDeleted', 'Children', 'Type'});
while ind <= length(args)
% perform partial matching and completion
paramname = validatestring(args{ind},names,nameoffset+ind);
outargs = [outargs paramname args(ind+1)]; %#ok<AGROW>
ind = ind + 2;
end
Image Analyst
on 29 Jan 2022
What is z?
whos z
Why are you passing in z into scatter() twice?
scatter(x,y,z,z, 'filled');
Cris LaPierre
on 29 Jan 2022
What version of MATLAB are you using? Your error message suggests R2019a, but if so, that is not the 2019a version of scatter.m.
CHARLES ADDEY
on 31 Jan 2022
I am using R2019a, probably i might have mixed up the scatter.m somewhere along the line while trying to resolve this issue.
Is there a way to reset the R2019a to the default installation state, or I should just uninstall and reinstall back. Thank you Cris
Cris LaPierre
on 31 Jan 2022
Edited: Cris LaPierre
on 31 Jan 2022
I'd suggest uninstalling and reinstalling. It may be possible to work out another way, but it would take much longer to work out via comments here.
Typically this error message happens when you save your script using the same name as MATLAB's function name. However, the tests above show that doesn't appear to be the case. Just thought it was worth pointing out so that you can be sure to avoid using those names going forward.
Walter Roberson
on 1 Feb 2022
scatter(x,y,z,z, 'filled');
is valid. It would use z as the spot size and also as the color indication.
More Answers (0)
See Also
Categories
Find more on Graphics Performance 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!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)