How to create function handle from fit struct after using curve fitting toolbox?

조회 수: 3 (최근 30일)
S.M.
S.M. 2018년 7월 13일
답변: S.M. 2018년 7월 13일
I have this struct as result of my curve fitting toolbox, now I need to create a function handle based on my spline coefficients. Can any one help?

답변 (4개)

Stephan
Stephan 2018년 7월 13일
Hi,
Why do you need this? You can directly compute new values for your fitresult:
y_new = fitresult(x_new)
This returns the vector corresponding to x_new, which should exactly be the result you expect from a function handle.
Best regards
Stephan
  댓글 수: 1
Stephan
Stephan 2018년 7월 13일
편집: Stephan 2018년 7월 13일
Iam not in the near of my computer to test it, but i think this should work:
f = @(x)fitresult(x)
ga should accept this function handle i think.
You can test:
y_expected = f(x_known)
If this returns the correct value for y you are fine.
Best regards
Stephan

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


S.M.
S.M. 2018년 7월 13일
I need to give it to Genetic Algorithm (ga) from Global Optimization toolbox, to find my global minimum. The ga needs function handle.

S.M.
S.M. 2018년 7월 13일
Or I have to write equation for it, which with spline fitting and 336 coefficients, is impossible.

S.M.
S.M. 2018년 7월 13일
I am almost done for today but I will try and see, thanks.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by