How do I use MatLab to find a line of best fit with a predetermined y intercept using regression.

22 次查看(过去 30 天)
I have data on changes in cardiac output with temperature changes from several studies. This data is expressed as CO at Tn / CO at T0, so at baseline temperature the result = 1. I want to find a line of best fit for this data, but the y intercept must be 1 for it to make sense.
How do I use Matlab find a line of best fit with least squares regression for this data, with the y intercept constrained to 1? It is easily done with Microsoft Excel, but I am trying to become more familiar with stats on Matlab.

采纳的回答

Star Strider
Star Strider 2022-12-18
Perhaps —
x = 0:250;
y = randn(size(x));
B0 = x(:) \ (y(:)-1)
B0 = -0.0054
fitline = x(:) * B0 + 1;
figure
plot(x, y, '.')
hold on
plot(x, fitline, '-r')
hold off
grid
.
  7 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Descriptive Statistics 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by