フィルターのクリア

Hello, I would like to know how to draw a shaded region like this?

71 ビュー (過去 30 日間)
Khadija
Khadija 2024 年 7 月 5 日 18:07
コメント済み: Star Strider 2024 年 7 月 14 日 1:02
I am trying to estimate the parameters for a mathematical model, I managed to do it but there remains a problem of determining the confidence interval and drawing the shaded region which contains the majority of the data points.
  1 件のコメント
Image Analyst
Image Analyst 2024 年 7 月 5 日 18:33
If you have any actual questions, then ask them and attach your data and code to read it in with the paperclip icon after you read this:

サインインしてコメントする。

採用された回答

Star Strider
Star Strider 2024 年 7 月 5 日 18:50
Perhaps something like this —
x = linspace(0, 5, 25).';
y = 5*exp(-0.5*x) + randn(size(x));
fcn = @(b,x) b(1).*exp(b(2).*x) + b(3);
B0 = randn(3,1);
mdl = fitnlm(x, y, fcn, B0)
mdl =
Nonlinear regression model: y ~ b1*exp(b2*x) + b3 Estimated Coefficients: Estimate SE tStat pValue ________ _______ _______ ________ b1 5.5856 1.9322 2.8908 0.008483 b2 -0.30843 0.24258 -1.2715 0.21684 b3 -1.3477 2.218 -0.6076 0.54968 Number of observations: 25, Error degrees of freedom: 22 Root Mean Squared Error: 0.997 R-Squared: 0.66, Adjusted R-Squared 0.629 F-statistic vs. constant model: 21.3, p-value = 7.13e-06
[ynew,yci] = predict(mdl, x);
figure
hp1 = plot(x, y, '.', 'DisplayName','Data');
hold on
hp2 = plot(x, ynew, '-r', 'DisplayName','Regression');
hp3 = plot(x, yci, '--r', 'DisplayName','95% CI');
hp4 = patch([x; flip(x)], [yci(:,1); flip(yci(:,2))], 'r', 'FaceAlpha',0.25, 'EdgeColor','none', 'DisplayName','Shaded Confidence Interval');
hold off
grid
xlabel('X')
ylabel('Y')
legend([hp1,hp2,hp3(1),hp4], 'Location','best')
.
  10 件のコメント
Khadija
Khadija 2024 年 7 月 14 日 0:41
Thank you very much for your patience!!
Star Strider
Star Strider 2024 年 7 月 14 日 1:02
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with Curve Fitting Toolbox についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by