필터 지우기
필터 지우기

Plot error bars in curve fitting figure

조회 수: 13 (최근 30일)
Pietro Scapolo
Pietro Scapolo 2022년 11월 21일
답변: Star Strider 2022년 11월 21일
Hi I would like to know how to add error bars to the figure of the curve fitter.

답변 (1개)

Star Strider
Star Strider 2022년 11월 21일
Using fitnlm since I am familiar with it —
x = 0:20;
y = 1-exp(-0.25*x) + randn(size(x))*0.1;
objfcn = @(b,x) b(1) - exp(b(2).*x) + b(3);
mdl = fitnlm(x(:),y(:), objfcn, rand(3,1))
Warning: The Jacobian at the solution is ill-conditioned, and some model parameters may not be estimated well (they are not identifiable). Use caution in making predictions.
mdl =
Nonlinear regression model: y ~ b1 - exp(b2*x) + b3 Estimated Coefficients: Estimate SE tStat pValue ________ ________ _______ __________ b1 434.96 0.015592 27897 8.6967e-74 b2 -0.25979 0.037878 -6.8586 1.5222e-06 b3 -433.96 0.015592 -27833 9.0871e-74 Number of observations: 21, Error degrees of freedom: 19 Root Mean Squared Error: 0.0806 R-Squared: 0.92, Adjusted R-Squared 0.916 F-statistic vs. constant model: 219, p-value = 6.94e-12
[yf,yci] = predict(mdl, x(:));
figure
plot(x, y, '.:')
hold on
errorbar(x, yf, yci(:,1)-yf, yci(:,2)-yf)
hold off
grid
xlim([-1 21])
A similar approach would likely work with the Curve Fitting Toolbox functions.
It will be necessary for you to experiment with those in your project.
.

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by