フィルターのクリア

Nested for loop, too slow

3 ビュー (過去 30 日間)
Raffaele Giammetti
Raffaele Giammetti 2019 年 4 月 26 日
コメント済み: Raffaele Giammetti 2019 年 4 月 28 日
Hello, I have a 2464 x 2464 matrix (44 block matrixes 56x56). I need an algorithm to put at 0 at each iteration the rows and columns i, i + 56, i + 112, i + 168 .... i + 2352.
I wrote this:
for j=1:56
D=A;
for i=1:43
D(j,1:end)=0;
D(1:end,j)=0;
for m=j+(i*56)
D(m,1:end)=0;
D(1:end,m)=0;
end
C=D;
xlswrite('results.xlsx',C,j);
end
end
and, apparently, it works, but it's so slow. Too slow! Any suggestion?

採用された回答

Bob Thompson
Bob Thompson 2019 年 4 月 26 日
編集済み: Bob Thompson 2019 年 4 月 26 日
It looks like you want to blank the entire row, correct?
A = 1:56:2464;
D(A,:) = 0;
EDIT** Change variable names as you need to, I just used generic ones without looking at what exactly you used.
  1 件のコメント
Raffaele Giammetti
Raffaele Giammetti 2019 年 4 月 28 日
Yes, so simple so perfect. Shame on me!
Thank you very much :)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by