フィルターのクリア

Speed up for loops for arrays

1 回表示 (過去 30 日間)
Mantas Vaitonis
Mantas Vaitonis 2018 年 11 月 9 日
編集済み: madhan ravi 2018 年 11 月 9 日
Hello, Maybe someone could help me to speedup this type of for loop? I did try parfor, I did try to think of way using GPU, but it does not work with indexing.
clear;
a=7811200001;
d=1083355908;
c=zeros(1083355908,1)
parfor i = 1:d
c(i,1)=a+i;
end

採用された回答

madhan ravi
madhan ravi 2018 年 11 月 9 日
編集済み: madhan ravi 2018 年 11 月 9 日
a=7811200001;
d=1083355908;
c=a+(1:d);
c=(a+1):(a+d); %edited after jan's comment
  10 件のコメント
Jan
Jan 2018 年 11 月 9 日
Another hint: In a+(1:d) you create the double vector 1:d at first and then add a to each element. It is more efficient to omit the addition and create vector directly:
(a+1):(a+d)
madhan ravi
madhan ravi 2018 年 11 月 9 日
編集済み: madhan ravi 2018 年 11 月 9 日
Selbverständlich , danke schön @Jan

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by