I have this error: ''Execution of script plot as a function is not supported: C:\Users\Jonathan e Leonardo\Documents\MATLAB\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
JONATHAN LAZZARESCHI
2022년 1월 24일
Steven Lord
2022년 1월 24일
@JONATHAN LAZZARESCHI If the answer from @Alagu Sankar Esakkiappan resolved the problem please indicate that by accepting that answer. Thanks.
Anushree
2023년 8월 24일
I have named my file as dsp1 but still not working...
Akshith
2023년 11월 3일
even i am getting this error whenever i am doing matlab
Akshith
2023년 11월 3일
how to sort this error?
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
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
I can run that script without a problem:
plot
but if I try to call the plot function included in MATLAB I receive an error.
plot(1:10, 1:10)
If I were to delete the plot.m script, I would be able to call the plot function in MATLAB.
채택된 답변
추가 답변 (3개)
Junran Chen
2023년 12월 15일
1 개 추천
Hi, change your file name from plot.m to another thing will work.
댓글 수: 2
Ahmad Sharif
2024년 6월 17일
It worked to me. My filname is subplot.m
DINESH PRASAD REDDY
2025년 1월 23일
GOAT
Xinchang
2024년 3월 4일
0 개 추천
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.
카테고리
도움말 센터 및 File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!