Curve fitting toolbox issue: custom equation produced imaginary part
11 ビュー (過去 30 日間)
古いコメントを表示
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)
0 件のコメント
回答 (1 件)
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
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Interpolation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!