필터 지우기
필터 지우기

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

조회 수: 21 (최근 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
Chris Joyce
Chris Joyce 2022년 12월 18일
It works perfectly, giving me exactly the same answers as EXCEL.
Thanks again
Star Strider
Star Strider 2022년 12월 18일
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by