How do I fix: "Undefined function 'fit' for input arguments of type 'function_handle'."?

조회 수: 5 (최근 30일)
Jacob
Jacob 2013년 10월 5일
댓글: Walter Roberson 2013년 10월 5일
I'm not entirely understanding the reason why the follow code doesn't work:
close all; clear all;
x = [2 4 6 8 10];
y = [0.18 0.45-.05 0.85-.1 1.35-.15 2-.2];
fun = @(a,b,c,x) -sqrt(a^2-(x-b).^2)+c;
guess = fun(15,0,15,x); % fun(a,b,c,x)
plot(x,guess,'r:')
fittedmodel = fit(x',y',fun,'StartPoint',[15 0 15])
plot(fittedmodel,'r-');
When I run the code I get the following error:
Undefined function 'fit' for input arguments of type 'function_handle'.
How can I fix this?
Thank you.

답변 (1개)

Walter Roberson
Walter Roberson 2013년 10월 5일
Which MATLAB version are you using?
Ensure that you have the Curvefitting toolbox installed and licensed. Use
which -all fit
  댓글 수: 2
Jacob
Jacob 2013년 10월 5일
편집: Walter Roberson 2013년 10월 5일
I'm using version 2013a.
When I use 'which -all fit' I have an output showing that I have the following libraries within my toolbox:
gmdistribution method
ProbDistUnivParam method
NaiveBayes method
Does this mean I'm missing some libraries to use the fit function I would like to use or do I have to readjust my parameters to those methods?
Walter Roberson
Walter Roberson 2013년 10월 5일
It does appear that you are missing the Curvefitting Toolbox.

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

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by