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

17 vues (au cours des 30 derniers jours)
Josh Crunk
Josh Crunk le 6 Fév 2019
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 commentaire
Josh Crunk
Josh Crunk le 7 Fév 2019
I have unistalled and reinstalled this version of MatLab on my computer and the problem continues.

Connectez-vous pour commenter.

Réponses (7)

Star Strider
Star Strider le 7 Fév 2019
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 commentaires
Star Strider
Star Strider le 7 Fév 2019
Use the Contact Us link to request Technical Support from MathWorks.
Rik
Rik le 1 Août 2019
Comment posted as flag by Andreas Junge:
I had the same message, after the commands Problem was solved!

Connectez-vous pour commenter.


Matt Gaidica
Matt Gaidica le 7 Fév 2019
Try:
open plot
See if plot is a variable or if the project has redefined it.
  4 commentaires
bo xiang
bo xiang le 26 Oct 2020
here is me wondering why plot(x1,y1,'k--r+') is an error...
Rik
Rik le 26 Oct 2020
@bo xiang, What color do you want your plot to be? Black or red?

Connectez-vous pour commenter.


Veda Upadhye
Veda Upadhye le 19 Fév 2019
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 commentaire
Rik
Rik le 28 Mar 2020
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.

Connectez-vous pour commenter.


Nurye Hassen
Nurye Hassen le 6 Août 2020
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 le 6 Août 2020
Modifié(e) : Nurye Hassen le 6 Août 2020
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 le 7 Déc 2022
Changing the script name worked for me

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by