Polyfit built-in function not supported

조회 수: 9 (최근 30일)
Bryant
Bryant 2025년 4월 16일
답변: Steven Lord 2025년 4월 16일
I'm trying to use the built-in function 'polyfit' in MATLAB, and everytime I copy and paste the code from the MATLAB website, i get the same error: "polyfit as a function is not supported." I don't know why my MATLAB progam wouldn't have a function it's supposed to have. Do I have to download the command? How do I resolve this predicament?
  댓글 수: 1
Walter Roberson
Walter Roberson 2025년 4월 16일
Experiment with
whos polyfit
which -all polyfit
to see whether you have a variable named polyfit. If not, then please post the exact error message.

댓글을 달려면 로그인하십시오.

답변 (1개)

Steven Lord
Steven Lord 2025년 4월 16일
I suspect that's not the full and exact text of the error message. Please show us all the text displayed in red in the Command Window (and if there are any warning messages displayed in orange, please show us those too.) The exact text may be useful and/or necessary to determine what's going on and how to avoid the warning and/or error.
If I had to guess, I suspect you've created your own script file named polyfit.m. If you do that, shadowing the polyfit function included in MATLAB, MATLAB will try to call your script as a function when you call polyfit with input arguments and that's not allowed.
For example, the logo.m file is a script file included as part of MATLAB. What happens if you try to call it like a function?
logo(5)
Execution of script logo as a function is not supported:
/MATLAB/toolbox/matlab/general/logo.m

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by