Passing a variable into the fittype function

16 ビュー (過去 30 日間)
Peter
Peter 2013 年 7 月 19 日
Hello,
I have an analytical equation that I wish to fit to some data. I tried it out using the cftool command and it works well. From cftool I automatically generated an m-file in which part of the fit routine looks like this:
ft_ = fittype('2*erf(x)/a+b',... 'dependent',{'y'},'independent',{'x'},... 'coefficients',{'a', 'b'});
where a and b are the coefficients I allow the algorithm to play with to get the best fit.
The problem is that I want to introduce a new variable, c, which changes as follows:
ft_ = fittype('c*erf(x)/a+b',... 'dependent',{'y'},'independent',{'x'},... 'coefficients',{'a', 'b'});
If I do this I get the error message: undefined variable 'c' etc..
I've tried calling a separate function from within fittype where I bring in c from elsewhere, but I get the same error message:
ft_ = fittype('Analytical(x,a,b,c)',... 'dependent',{'y'},'independent',{'x'},... 'coefficients',{'a', 'b'});
Is there something obvious I'm doing wrong?
Best Regards
Pete

回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear and Nonlinear Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by