polynomial curve fitting error
3 visualizzazioni (ultimi 30 giorni)
Hi i have a simple problem but strange error. am doing a polynomial curve fitting for two column vectors x and y. i use command "p = polyfit(x,y,3) . It gives me following error
Attempt to execute SCRIPT polyfit as a function:
What could be the possible reason for it. Many thanks
John D'Errico il 5 Apr 2023
Modificato: John D'Errico il 5 Apr 2023
Is there a good reason why you called the script you wrote polyfit?
Yes, I suppose you had a very good reason, because you wanted to write a script to use polyfit. But now consider what happens to MATLAB. Does it know what you intended when you then try to use polyfit. Which one should it use? The script, named polyfit, or the original function, also named polyfit? It tries to do its best, but it is confused. Never confuse a computer. It might get upset, and then go hack your checking account. ;-) These blasted computers sometimes can be vengeful things.
DO NOT NAME YOUR SCRIPTS OR YOUR OWN FUNCTIONS WITH THE NAMES OF EXISTING MATLAB FUNCTIONS. Do this at the command prompt:
whch polyfit -all
Then, rename your script.
Più risposte (1)
Sam Chak il 5 Apr 2023
If, for some reasons, you like to name your script "polyfit.m", try adding a prefix to make the filename unique.
Here are some examples:
Before saving the filename, you can check if the chosen filename exists in other MATLAB folders or not.
which myPolyFit -all
which PolyFit -all