Curve Fitting with Individual trial function

Hello,
matlab offers the possibility to approximate numerical data by a function like polynomials, exponential function etc! Is there a way to do this with an individual trial function like f(x)= a*sqrt(x)*(b*x^2+exp(c*x) or something like that. If the number of (x,y) pairs is the same like the number of coefficients to be determined in my trial equotation, it could be done with a nonlinear equotation system but i want the curve it to be approximated!
Thanks for your help

댓글 수: 1

Star Strider
Star Strider 2012년 7월 13일
See ‘lsqcurvefit’ or ‘nlinfit’. If you don't have access to these, you can use ‘fminsearch’ to do nonlinear curve fitting.

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

 채택된 답변

Tom Lane
Tom Lane 2012년 7월 13일

0 개 추천

If you are talking about the Curve Fitting Toolbox, try this:
f = @(a,b,c,x) a*sqrt(x).*(b*x.^2+exp(c*x))
y = f(1,2,-3,x) + randn(size(x))/100;
plot(x,f(1,2,-3,x),'b.')
fit(x,y,f)
You could also enter the expression into the cftool window. Notice that I vectorized your expression, for example changing "^" to ".^" to get element-by-element operations on the vector x.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

질문:

2012년 7월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by