Calculate trends with regression for columns in MATLAB
1 回表示 (過去 30 日間)
古いコメントを表示
ali karbalaee
2020 年 10 月 3 日
コメント済み: ali karbalaee
2020 年 10 月 3 日
I have a matrix with dimensions of 19 rows and 7541502 columns. I want to get the trend of each column using regression. This is possible by using MATLAB function but requires a lot of time. The written function is as follows:
Data = box1;
[r, c] = size(Data);
X = [1:r]'; Total = nan(c,3);
for j = 1:c;
Y = Data(:, j);
[b1, bint1] = regress(Y, [ones(size(Y)) X]);
Qs = [bint1(2, :), b1(2, :)];
Total = [Total; Qs];
end
Is there a way to speed up Mfile in MATLAB? Is there a way to calculate regression without using functions?
Thanks in advance.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/370390/image.jpeg)
0 件のコメント
採用された回答
Abdolkarim Mohammadi
2020 年 10 月 3 日
編集済み: Abdolkarim Mohammadi
2020 年 10 月 3 日
You can use parfor (parallel for loop) instead of for. The more CPU cores you have, the more speed you gain.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Linear Regression についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!