Attempt to execute SCRIPT plot as a function,how to solve it?

3 Ansichten (letzte 30 Tage)
Fahima Sarmin
Fahima Sarmin am 2 Dez. 2024
Bearbeitet: John D'Errico am 2 Dez. 2024
Attempt to execute SCRIPT plot as a function
  2 Kommentare
Fahima Sarmin
Fahima Sarmin am 2 Dez. 2024
Bearbeitet: Fahima Sarmin am 2 Dez. 2024
error in the command window, how to solve it?
dpb
dpb am 2 Dez. 2024
You've named another m-file script as plot; you chose plot2 for this one, but even that is prone to making the mistake; I'd suggest choosing/using a name descriptive of your purpose to avoid accidentally doing it again in the future.
Try
which -all plot
and it will show you all the plot() functions the system can find; all of them should be in the base MATLAB \toolbox or other MATLAB folders; it will then also show you the one you have created; make sure it isn't something you really need to keep; if it's just a mistake, then delete it, otherwise rename it to something else.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

John D'Errico
John D'Errico am 2 Dez. 2024
Bearbeitet: John D'Errico am 2 Dez. 2024
Don't name your script plot.
In general, don't use existing names of supplied functions for your own functions or scripts. You can do so of course, but then you have the unhappy result of needing to ask here what happened.
If you don't think you did this, do this test at the command prompt:
which plot -all
You will find that indeed, you have named a script with the name plot. Yes, it seemed like a logical thing to do, since you wanted to plot, but it confuses MATLAB. And computers are so easily confused. (It could have been worse of course. You might have decided to name your code SkyNet, or something like that. I don't want to think of what may have gone wrong then.)

Kategorien

Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by