フィルターのクリア

How to store the result of a loop in a cell?

1 回表示 (過去 30 日間)
Joseph
Joseph 2019 年 1 月 17 日
コメント済み: Joseph 2019 年 1 月 17 日
Hi everyone
i have a matrix R(12*44) and X(12*1). i'm trying to take a linear regression for each column of matrix R in a for loop and store in a cell such as b, but seems like it just stores the regression of the last column. can you please help. here is the script that i'm using.
X=[ones(size(R(:,1))) X];
b=cell(44,1);
for i=44
c=regress(R(:,i),X);
b{i}=c;
end;
Thank you

採用された回答

Stephen23
Stephen23 2019 年 1 月 17 日
編集済み: Stephen23 2019 年 1 月 17 日
Your code is only iterating once, because
for i = 1:44
^^ you forgot this.
PS: I would recomend using ii or k as the loop iterator variable, because i is the imaginary unit.
  1 件のコメント
Joseph
Joseph 2019 年 1 月 17 日
Oh shoot, i'm an idiot. you wouldn't believe if i told you i was thinking about this for like 5 hours! thanks :|

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by