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

38 次查看(过去 30 天)
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