How would I perform a linear regression with a for loop on a set of data without using a GUI

1 回表示 (過去 30 日間)
sunny blue
sunny blue 2021 年 10 月 17 日
コメント済み: Jan 2021 年 10 月 17 日
So if I had a set of data X and Y of the same length
How would I do a linear regression with a for loop. I created a separate value xi where i have points of evaluation that spans the domain.
I would want to fit it to the curve Y= a*X+b and Y=A*X^b etc etc.
The equation I want it to run in the loop i've attached below. please help
  3 件のコメント
sunny blue
sunny blue 2021 年 10 月 17 日
I would need the two curves that I showed above and
y = a*(x/(x+b))
log(y) = a*log(a) + b
i would like to use a for loop for the linear one at the very least because that is what i have been told to use.
for arrays X and Y
x=0:1000;
for xi=1:length(x)
it = find((X<x(xi)),1,'last')
Y(xi)=Y(it)+(Y(it+1)-Y(it))/(X(it+1)-X(it)) * (x(xi)-X(it));
end
Jan
Jan 2021 年 10 月 17 日
I'm not sure, what your question is.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear and Nonlinear Regression についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by