How to extract the function from curve fitting tool in Matlab

조회 수: 44 (최근 30일)
zein
zein 2020년 12월 17일
댓글: zein 2021년 1월 8일
I want to extract the function for my data points. I used interpolant witg linear method as indicated in the figure below.
Is it possible to extract a function for the new curve produced by curve fitting as i want to integrate the equation to get the area under the curve?

채택된 답변

Steven Lord
Steven Lord 2020년 12월 22일
You can call integrate on the cfit object. See the documentation page for more information.

추가 답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 12월 17일
편집: Ameer Hamza 2020년 12월 17일
No, in the case of interpolated curve fitting, it is not possible to get a nice and simple equation. It uses several linear equations in a piecewise manner to create the curve. However, it is still possible to integrate it. First, export the model to the workspace by right-clicking it in the "Table of Fits" section. The export model (name it fittedmodel in this example) supports functional syntax to evaluate the value. For example, you can write
fittedmodel(0.01)
to get the value at x = 0.01. You can integrate it like this
integral(@(x) fittedmodel(x).', 0, 0.03)
  댓글 수: 3
Ameer Hamza
Ameer Hamza 2020년 12월 22일
Yes, this syntax is correct.
zein
zein 2021년 1월 8일
Is it possible to differentiate the save function for different values of x?

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

카테고리

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

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by