フィルターのクリア

how to sum matrices in a for loop

15 ビュー (過去 30 日間)
reza hamzeh
reza hamzeh 2019 年 10 月 21 日
回答済み: David Hill 2019 年 10 月 22 日
hi every body. suppose the bellow code. this code give me 16 matrices. how can i sum all of this matrices by using these for-loops?
for i=1:4
for j=1:4
a=[0 1:1 0];
b=[1 0:0 1];
x=i*a+j*b;
end
end

採用された回答

David Hill
David Hill 2019 年 10 月 22 日
I assume you just want to add the calculated x-matrix with itself during each loop iteration.
x=zeros(2);
for i=1:4
for j=1:4
a=[0 1:1 0];
b=[1 0:0 1];
x=x+i*a+j*b;
end
end

その他の回答 (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