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!