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
Abdallah Ghazi Faisal Zaid Alkilani 2020 年 3 月 28 日
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 Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by