필터 지우기
필터 지우기

GridSearchCV , what is fittingfunction ?

조회 수: 13 (최근 30일)
shawin
shawin 2023년 7월 5일
댓글: Neev 2023년 7월 5일
Hi,
irstparam = [1, 2, 3.3, 3.7, 8, 21]; %list of places to search for first parameter
secondparam = linspace(0,1,20); %list of places to search for second parameter
[F,S] = ndgrid(firstparam, secondparam);
fitresult = arrayfun(@(p1,p2) fittingfunction(p1,p2), F, S); %run a fitting on every pair fittingfunction(F(J,K), S(J,K))
[minval, minidx] = min(fitresult);
bestFirst = F(minidx);
bestSecond = S(minidx);
I tried to run the above code, but i have the error below :
Unrecognized function or variable 'fittingfunction'.
Please could you help ?
I need to know what fitting function should i use ?
fit() not worked ?

답변 (1개)

Neev
Neev 2023년 7월 5일
Hey Shawin
I have tried to reproduce the code and you will not face the error if you add a line to define your fitting function before initialising firstparam array as below:
fittingfunction = @(p1, p2) p1^2 + p2^2;
You can replace the above equation with the actual fitting function you may want to use, so that you do not face the same error that you are facing presently.
I hope I was of help :)
  댓글 수: 2
shawin
shawin 2023년 7월 5일
Thank you the error gone.
but the code alwayes select the min values ?
1,0 !!!!
Neev
Neev 2023년 7월 5일
You can change that according to your desired output. Just put in constraints for the same.

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

카테고리

Help CenterFile Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by