ln not recognised as a command

조회 수: 7 (최근 30일)
Niels
Niels 2013년 7월 25일
Hello
I've entered the following formula in a function file:
heightModel = @(params,ages) (params(3)+params(4).*(ages/12)+params(5).*log((1+(ages/12))).*(1-exp(1).^(-exp(1).^(params(1)-params(2).*(ages/12))))+params(6).*exp(1).^(-exp(1).^(params(1)-params(2).*(ages/12)))); modelStrings = {'A','B','C','D','E','U'};
this works perfect but is not the good formula. The only thing that needs to change is the log in a ln
but if i do this i get the following error Undefined function 'ln' for input arguments of type 'double'.
Error in getModel/@(params,ages)(params(3)+params(4).*(ages/12)+params(5).*ln((1+(ages/12))).*(1-exp(1).^(-exp(1).^(params(1)-params(2).*(ages/12))))+params(6).*exp(1).^(-exp(1).^(params(1)-params(2).*(ages/12))))
Error in lsqcurvefit (line 199) initVals.F = feval(funfcn_x_xdata{3},xCurrent,XDATA,varargin{:});
Error in fitFilteredModel (line 13) [parameters,resnorm,residual,exitflag,output] = lsqcurvefit(heightModel,initialValues,filteredData(:,1),filteredData(:,2));
Error in main (line 43) fitFilteredModel(ages(i),models{k},genders{j},data,individualFit);
Caused by: Failure in initial user-supplied objective function evaluation. LSQCURVEFIT cannot continue.
Anyone willing to help me out. I'm a biologist so my coding knowledge is very limited.
Thanks

채택된 답변

Iain
Iain 2013년 7월 25일
You can fix it by putting:
ln = @(x)(log(x));
at the start of your code...
or replace ln with "log"
  댓글 수: 1
Jan
Jan 2013년 7월 25일
Faster alternatively: ln = @log

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

추가 답변 (1개)

Evan
Evan 2013년 7월 25일
편집: Evan 2013년 7월 25일
help log
If you read the help file for log, you'll see that it is the natural logarithm function. ln is not a built-in function. log10 is the function for computing the base-10 logarithm.

카테고리

Help CenterFile Exchange에서 Genetic Algorithm에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by