I have this error: ''Execution of script plot as a function is not supported: C:\Users\Jonathan e Leonardo\D​ocuments\M​ATLAB\plot​.m''

I have this error: ''Execution of script plot as a function is not supported:
C:\Users\Jonathan e Leonardo\Documents\MATLAB\plot.m''
How can I resolve it?

7 commentaires

"How can I resolve it?"
Do not name your script plot: rename your script to something else (not the name of a MATLAB function).
@JONATHAN LAZZARESCHI If the answer from @Alagu Sankar Esakkiappan resolved the problem please indicate that by accepting that answer. Thanks.
I have named my file as dsp1 but still not working...
even i am getting this error whenever i am doing matlab
Use which -all on the name that MATLAB says was a script that you expected to be a function. More likely than not you've defined your own file with the same name as a function in MATLAB or another MathWorks product and so your file is shadowing (taking precedence over) the function in the MathWorks product. Rename your file or remove it.
As an example, if I created a script file plot.m:
% Change to a new temporary directory into which I can write the file
newlocation = tempname;
mkdir(newlocation)
cd(newlocation)
% Create the file using low-level file I/O functions
fid = fopen(fullfile(pwd, 'plot.m'), 'wt');
fprintf(fid, "x = 1+1");
fclose(fid);
and ask what plot refers to:
which -all plot
Warning: Function plot has the same name as a MATLAB built-in. We suggest you rename the function to avoid a potential name conflict.
Warning: Function plot has the same name as a MATLAB built-in. We suggest you rename the function to avoid a potential name conflict.
/tmp/tp3a79b330_05bc_42e0_8712_09c278bc7e8b/plot.m built-in (/MATLAB/toolbox/matlab/graph2d/plot) % Shadowed /MATLAB/toolbox/matlab/graphics/math/@digraph/plot.m % digraph method /MATLAB/toolbox/matlab/graphics/math/@graph/plot.m % graph method /MATLAB/toolbox/matlab/timeseries/@timeseries/plot.m % timeseries method /MATLAB/toolbox/matlab/graphics/math/@polyshape/plot.m % polyshape method /MATLAB/toolbox/matlab/graphics/math/@alphaShape/plot.m % alphaShape method /MATLAB/toolbox/matlab/bigdata/@tall/plot.m % tall method /MATLAB/toolbox/bioinfo/bioinfo/@phytree/plot.m % phytree method /MATLAB/toolbox/bioinfo/microarray/@HeatMap/plot.m % HeatMap method /MATLAB/toolbox/bioinfo/microarray/@clustergram/plot.m % clustergram method /MATLAB/toolbox/curvefit/curvefit/@cfit/plot.m % cfit method /MATLAB/toolbox/curvefit/curvefit/@sfit/plot.m % sfit method /MATLAB/toolbox/econ/econ/@conjugateblm/plot.m % conjugateblm method /MATLAB/toolbox/econ/econ/@diffuseblm/plot.m % diffuseblm method /MATLAB/toolbox/econ/econ/@mixconjugateblm/plot.m % mixconjugateblm method /MATLAB/toolbox/econ/econ/@lassoblm/plot.m % lassoblm method /MATLAB/toolbox/econ/econ/@mixsemiconjugateblm/plot.m % mixsemiconjugateblm method /MATLAB/toolbox/econ/econ/@empiricalblm/plot.m % empiricalblm method /MATLAB/toolbox/econ/econ/@blm/plot.m % blm method /MATLAB/toolbox/econ/econ/@customblm/plot.m % customblm method /MATLAB/toolbox/econ/econ/@semiconjugateblm/plot.m % semiconjugateblm method /MATLAB/toolbox/ident/ident/@iddata/plot.m % iddata method /MATLAB/toolbox/ident/nlident/@idnlarx/plot.m % idnlarx method /MATLAB/toolbox/ident/nlident/@idnlhw/plot.m % idnlhw method /MATLAB/toolbox/mpc/mpc/@mpc/plot.m % mpc method /MATLAB/toolbox/risk/risk/@varbacktest/plot.m % varbacktest method /MATLAB/toolbox/robust/rctobsolete/robust/@frd/plot.m % frd method /MATLAB/toolbox/robust/robust/@umargin/plot.m % umargin method /MATLAB/toolbox/shared/channel/rfprop/@propagationData/plot.m % propagationData method /MATLAB/toolbox/shared/drivingscenario/@drivingScenario/plot.m % drivingScenario method /MATLAB/toolbox/signal/signal/@dspdata/plot.m % dspdata method /MATLAB/toolbox/stats/bayesoptim/@BayesianOptimization/plot.m % BayesianOptimization method /MATLAB/toolbox/stats/classreg/@LinearModel/plot.m % LinearModel method /MATLAB/toolbox/wavelet/wavelet/@dtree/plot.m % dtree method /MATLAB/toolbox/wavelet/wavelet/@wdectree/plot.m % wdectree method /MATLAB/toolbox/wavelet/wavelet/@ntree/plot.m % ntree method
I see the script I just created is the first item on the list. [I also receive warnings.]
You can see that the plot.m file MATLAB finds first is the one I created:
type plot.m
x = 1+1
I can run that script without a problem:
plot
x = 2
but if I try to call the plot function included in MATLAB I receive an error.
plot(1:10, 1:10)
Execution of script plot as a function is not supported:
/tmp/tp3a79b330_05bc_42e0_8712_09c278bc7e8b/plot.m
If I were to delete the plot.m script, I would be able to call the plot function in MATLAB.

Connectez-vous pour commenter.

 Réponse acceptée

Hi Jonathan,
Aforementioned error occurs as plot is already an internal implemented function in MATLAB. You may check if there is any internal implementation already done for any specific function using which commmand:
which plot -all
This problem can be resolved by using a different filename for the current script, which is not already used for any other internal function in MATALB.

6 commentaires

mine is giving me the same error, except mine is named "HW2Problem1"
Hi, I've came across the same error in MATLAB and I've changed the flinename for the script multiple times but it doesn't fix the issue.
For the script that is listed in the error message you receive, what does the command posted in the accepted answer show when you run it using that script name? So if your error message says that "Execution of script max as a function is not supported" (instead of plot) you would type:
which max -all
built-in (/MATLAB/toolbox/matlab/datafun/max) built-in (/MATLAB/toolbox/matlab/datafun/@double/max) % double method built-in (/MATLAB/toolbox/matlab/datafun/@int16/max) % int16 method built-in (/MATLAB/toolbox/matlab/datafun/@int32/max) % int32 method built-in (/MATLAB/toolbox/matlab/datafun/@int64/max) % int64 method built-in (/MATLAB/toolbox/matlab/datafun/@int8/max) % int8 method built-in (/MATLAB/toolbox/matlab/datafun/@logical/max) % logical method built-in (/MATLAB/toolbox/matlab/datafun/@single/max) % single method built-in (/MATLAB/toolbox/matlab/datafun/@uint16/max) % uint16 method built-in (/MATLAB/toolbox/matlab/datafun/@uint32/max) % uint32 method built-in (/MATLAB/toolbox/matlab/datafun/@uint64/max) % uint64 method built-in (/MATLAB/toolbox/matlab/datafun/@uint8/max) % uint8 method /MATLAB/toolbox/matlab/datatypes/categorical/@categorical/max.m % categorical method /MATLAB/toolbox/matlab/datatypes/tabular/@tabular/max.m % tabular method /MATLAB/toolbox/matlab/datatypes/datetime/@datetime/max.m % datetime method /MATLAB/toolbox/matlab/datatypes/duration/@duration/max.m % duration method /MATLAB/toolbox/matlab/timeseries/@timeseries/max.m % timeseries method max is a built-in method % connector.internal.LoggerLevel method max is a built-in method % matlab.internal.lang.capability.Capability method max is a built-in method % matlab.lang.OnOffSwitchState method max is a built-in method % matlab.internal.reference.property.RefEntityType method max is a built-in method % matlab.internal.reference.api.EntityPrecision method max is a built-in method % matlab.internal.reference.property.DeprecationStatus method max is a built-in method % matlab.internal.reference.property.FunctionType method max is a built-in method % matlab.internal.reference.property.SyntaxType method max is a built-in method % matlab.internal.reference.api.EntityCaseSensitivity method max is a built-in method % simulink.FindSystemTask.Status method max is a built-in method % mf.zero.meta.Language method max is a built-in method % dig.config.CommandType method max is a built-in method % dig.config.HorizontalAlignment method max is a built-in method % dig.model.DisplayState method max is a built-in method % dig.model.EventDataType method max is a built-in method % dig.model.FunctionType method max is a built-in method % dig.model.ValidInBdType method max is a built-in method % dig.model.ViewMode method max is a built-in method % dastudio_util.cooperative.AsyncFunctionRepeaterTask.Status method max is a built-in method % coderdictionary.data.AccessFunctionSignaturesEnum method max is a built-in method % coderdictionary.data.AccessInterfaceEnum method max is a built-in method % coderdictionary.data.AccessModeEnum method max is a built-in method % coderdictionary.data.AllowedAccessEnum method max is a built-in method % coderdictionary.data.DataAccessEnum method max is a built-in method % coderdictionary.data.DataAccessTypeEnum method max is a built-in method % coderdictionary.data.DataInitEnum method max is a built-in method % coderdictionary.data.DataInstantiationEnum method max is a built-in method % coderdictionary.data.DataTypeScopeEnum method max is a built-in method % coderdictionary.data.LatchingModeEnum method max is a built-in method % coderdictionary.data.PlacementEnum method max is a built-in method % coderdictionary.data.ScopeEnum method max is a built-in method % coderdictionary.data.StatementsSurroundEnum method max is a built-in method % coderdictionary.data.StatusEnum method max is a built-in method % matlab.unittest.internal.fixtures.FolderScope method max is a built-in method % matlab.automation.Verbosity method max is a Java method % java.lang.Long method max is a Java method % java.lang.Double method max is a built-in method % matlab.internal.timer.CallBackTypeEnum method max is a built-in method % matlab.internal.timer.BusyModeEnum method max is a built-in method % matlab.internal.timer.ExecutionModeEnum method max is a built-in method % matlab.graphics.chart.internal.ParserState method /MATLAB/toolbox/matlab/bigdata/@tall/max.m % tall method /MATLAB/toolbox/coder/half/@half/max.p % half method /MATLAB/toolbox/nnet/deep/@dlarray/max.m % dlarray method /MATLAB/toolbox/parallel/gpu/@gpuArray/max.m % gpuArray method /MATLAB/toolbox/parallel/parallel/@codistributed/max.m % codistributed method /MATLAB/toolbox/symbolic/symbolic/@sym/max.m % sym method
Still I'm not getting the figure
Nobody knows what your filenames/path are, what errors you're seeing, or what you tried to do to fix it. It's up to you to describe the problem you have.
Is the error the same error as in the title? If so, what's the output of which()?

Connectez-vous pour commenter.

Plus de réponses (3)

Hi, Jonathan,
I had the same issue which has been solved now. The reason is that he name of my script is plot.m which same as one of the MATLAB function (plot) names. After I change it the output is normal. You can change the script name like test.m and try again.
Execution of script conv as a function is not supported:
C:\Users\DELL\Documents\MATLAB\conv.m

1 commentaire

Do not name your script conv: rename your script to something else (not the name of a MATLAB function).

Connectez-vous pour commenter.

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by