Create confidence interval for linear regression line

34 次查看(过去 30 天)
Hi, how can I plot a confidence interval bound for the regresison line using lsline? The code I wrote is this:
clc, clear all, close all
X(:,1) = (1:1:100);
X(:,2) = rand(100,1);
figure;
hold on
plot(X(:,1),X(:,2),'b*','MarkerSize',5);
h = lsline;
set(h,'color','g','LineWidth',3)
%s = lsline + 0.95 * h;
title 'TRY';
xlabel 'X';
ylabel 'Y';
hold off
Thank you

采纳的回答

Star Strider
Star Strider 2019-6-26
I would use the fitlm (link) function to calculate the regression line, the the predict function to calculate the confidence intervals. If you want to use polyfit and polyval instead, you can use the File Exchange contribution polypredci.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Support Vector Machine Regression 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by