Why won't anything plot? 6 errors in 3 lines of code.

조회 수: 17 (최근 30일)
Josh Crunk
Josh Crunk 2019년 2월 6일
답변: John-Paul Ayrton 2022년 12월 7일
I'm working on a larger project and it wouldn't plot and gave me a bunch of errors about things that weren't even a part of my code. I tried a simple code to see if it wiuld plot, but I'm getting the same errors. I've closed and reloaded MatLab and it continues to error.
x = [1 2 3 4 5];
y = [1 2 3 4 5];
plot(x,y)
Above is the code to plot and below are the errors.
>> Untitled
Undefined function 'claNotify' for input arguments of type 'matlab.graphics.axis.Axes'.
Error in cla (line 42)
claNotify(ax,extra{:});
Error in newplot>ObserveAxesNextPlot (line 152)
cla(ax, 'reset', hsave);
Error in newplot (line 93)
ax = ObserveAxesNextPlot(ax, hsave);
Error in matlab.graphics.internal.newplotwrapper (line 12)
axReturn = newplot(varargin{:});
Error in Untitled (line 3)
plot(x,y)
I'm running MATLAB R2018b - academic use. Thanks for any suggestions.
  댓글 수: 1
Josh Crunk
Josh Crunk 2019년 2월 7일
I have unistalled and reinstalled this version of MatLab on my computer and the problem continues.

댓글을 달려면 로그인하십시오.

답변 (7개)

Star Strider
Star Strider 2019년 2월 7일
It’s always worth running these commands:
restoredefaultpath
rehash toolboxcache
from your Command Window (or a script) before you click on the Contact Us link in the upper right corner of this page to ask MathWorks for Technical support. (If you need to do that, run the ver command first.)
  댓글 수: 3
Star Strider
Star Strider 2019년 2월 7일
Use the Contact Us link to request Technical Support from MathWorks.
Rik
Rik 2019년 8월 1일
Comment posted as flag by Andreas Junge:
I had the same message, after the commands Problem was solved!

댓글을 달려면 로그인하십시오.


Matt Gaidica
Matt Gaidica 2019년 2월 7일
Try:
open plot
See if plot is a variable or if the project has redefined it.
  댓글 수: 4
bo xiang
bo xiang 2020년 10월 26일
here is me wondering why plot(x1,y1,'k--r+') is an error...
Rik
Rik 2020년 10월 26일
@bo xiang, What color do you want your plot to be? Black or red?

댓글을 달려면 로그인하십시오.


Veda Upadhye
Veda Upadhye 2019년 2월 19일
One possible explanation of this issue could be shadowing of 'plot' or built-in MATLAB functions that are internally used by 'plot'. You can verify this using the below example (for 'plot' and other functions in your error stack trace):
which -all plot

Abdallah Ghazi Faisal Zaid Alkilani
I had a similar issue and I think the culprit is a function called newplot.m.
newplot.m function has subfunctions inside that were not terminated with 'end'.
I added an 'end' statement for each function inside newplot.m:
  • function axReturn = newplot(hsave)
  • function fig = ObserveFigureNextPlot(fig, hsave)
  • function ax = ObserveAxesNextPlot(ax, hsave)
It has worked so far *fingers crossed*.
You can open the file to edit by typing >> open newplot;
I hope this helps.
  댓글 수: 1
Rik
Rik 2020년 3월 28일
I would be very careful with recommending people to edit internal Matlab functions. Those should not be edited, because you have no way of knowing what functions rely on the function behaving the exact way it does.
Apart from that: a function is allowed not to terminate with an end keyword, as long as non of the functions do so. This used to be the default; Matlab would even warn you about the unnecessary closing end statements.

댓글을 달려면 로그인하십시오.


Nurye Hassen
Nurye Hassen 2020년 8월 6일
Optionally, you can enter the variables X and Y on the command window, then select them from your workspoace then go to "Plots" tab on the top next to "Home" to choose the plot you need. That may help.

Nurye Hassen
Nurye Hassen 2020년 8월 6일
편집: Nurye Hassen 2020년 8월 6일
To solve the problem once and for all do the following on command window.
open plot
then right click on the plot file on the editor and select "show in folder" and check the path. For your case it should be where you installed the MATLAB like...
C:\Program Files\MATLAB\R2017b\toolbox\matlab\graph2d
if you got it in Documents or other folder delete all the files or ZIP and keep it far away.
Let me know if didn't solve it.

John-Paul Ayrton
John-Paul Ayrton 2022년 12월 7일
Changing the script name worked for me

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by