Curve fitting toolbox issue: custom equation produced imaginary part

11 ビュー (過去 30 日間)
Methawi Chomthong
Methawi Chomthong 2017 年 8 月 31 日
回答済み: Kris Fedorenko 2017 年 9 月 7 日
The fitting tool report this error "Custom equations must produce an output vector, matrix, or array that is the same size and shape as the input data. This custom equation fails to meet that requirement:" I suspected that it was becuase my custom equation could generate non-zero imaginary part, while the actual data I was trying to fit had only real part.
I cannot use 'real' to specify in the custom equation box in the GUI either
This is my equation real(87.68./(1+exp((-1.883-(-a+sqrt(b+c*(0.0172./(x+(1./(0.0101.*log(1.+exp(-0.0101.*(x-(-169.9979)))))))+(-0.0143).*x))))./1.385))+(-80.56)-(-d+sqrt(e+f.*((0.0172/(x+(1/(0.0101*log(1+exp(-0.0101*(x-(-169.9979))))))'))'+(-0.0143)*x))).*(4.00./(1+exp((2.551-(-a+sqrt(b+c*(0.0172./(x+(1./(0.0101.*log(1.+exp(-0.0101.*(x-(-169.9979)))))))+(-0.0143).*x))))./0.415))+(-0.44))./0.92)

回答 (1 件)

Kris Fedorenko
Kris Fedorenko 2017 年 9 月 7 日
Hi Methawi!
I was not able to reproduce your error using the " fit " function from the Curve Fitting Toolbox. Which fitting tool are you using?
Here is a simple example using your custom equation to fit a function.
load('simpledata.mat')
customfit = fit(x, data, @(a, b, c, d, e, f, x) custom_eq(a, b, c, d, e, f, x),...
'Robust', 'LAR')
fittedfunc = custom_eq(customfit.a, customfit.b, customfit.c, customfit.d, customfit.e, customfit.f, x);
figure;
plot(x, data, 'o')
hold on
plot(x, fittedfunc)
function y = custom_eq(a, b, c, d, e, f, x)
y = real(87.68./(1+exp((-1.883-(-a+sqrt(b+c*(0.0172./(x+(1./(0.0101.*log(1.+exp(-0.0101.*(x-(-169.9979)))))))+(-0.0143).*x))))./1.385))+(-80.56)-(-d+sqrt(e+f.*((0.0172/(x+(1/(0.0101*log(1+exp(-0.0101*(x-(-169.9979))))))'))'+(-0.0143)*x))).*(4.00./(1+exp((2.551-(-a+sqrt(b+c*(0.0172./(x+(1./(0.0101.*log(1.+exp(-0.0101.*(x-(-169.9979)))))))+(-0.0143).*x))))./0.415))+(-0.44))./0.92);
end

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by