Attempt to execute SCRIPT plot as a function,how to solve it?
3 ビュー (過去 30 日間)
古いコメントを表示
Attempt to execute SCRIPT plot as a function

2 件のコメント
dpb
2024 年 12 月 2 日
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.
回答 (1 件)
John D'Errico
2024 年 12 月 2 日
編集済み: John D'Errico
2024 年 12 月 2 日
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.)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Creating, Deleting, and Querying Graphics Objects についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!