필터 지우기
필터 지우기

How to fit a function with n-parameters

조회 수: 1 (최근 30일)
Simon Streit
Simon Streit 2018년 9월 12일
댓글: dpb 2018년 9월 13일
Hello,
I have Data (x,y) to which I want to fit a series of exponential functions like the following analytical function:
y = sum_i=1 to i=250 (A_i*exp(-x/tau_i))
This i tried to write in Matlab with vectors:
'sum(Ai.*exp(-x./taui),2)'
with Vectors Ai and taui each 1x250. I am not sure if it is possible to write it in this "vectorial" manner, but I don't know how to frame it otherwise.
The taui are known parameters and only the coefficients from Ai need to be fitted, so it is actually only a linear fit.
For the fitting i created a fittype:
myfittype = fittype('sum(Ai.*exp(-x./taui),2)','dependent',{'y'},'problem',{'taui'},'independent',{'x'},'coefficients',{'Ai'});
myfit = fit(x,y,myfittype,'StartPoints',Ai,'problem',taui);
Here occurs the Problem I am stuck with and you hopefully can help me out:
The fittype function seems not to take all vector entries as Parameters, but only the first.
So my question in general is: How can I create a function with n-parameters and fit to these parameters?
  댓글 수: 3
Simon Streit
Simon Streit 2018년 9월 13일
It really is a function with 250 terms and the plausibility lies in the following steps, where I'm doing a Laplace Transformation, so I get a spectral peak, which is broadnend due to several physical mechanics and therefore I need those many terms as kind of a sampling rate.
dpb
dpb 2018년 9월 13일
That's totally impractical with the fittype structure; while you can write an m-file to evaluate the equation, coefficients are specified as individual strings so you would have to have and try to dereference 500 separate variables; absolutely unworkable.
The likelihood of being able to estimate that many coefficients is also probably vanishingly small, but the only way I see feasible at all would be to build the model and try to solve with nlinfit

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by