Am unable to wrap my head on this question regarding for loop , can someone explain the question and maybe write the code please.

2 ビュー (過去 30 日間)

採用された回答

Awais Saeed
Awais Saeed 2021 年 11 月 10 日
Why use a loop if it can be done without it
A = [1 2 3; 4 5 6; 7 8 9];
[sum_of_elements] = halfsum(A)
sum_of_elements = 26
function [sum_of_elements] = halfsum(M)
A = M;
sum_of_elements = sum(triu(A), 'all');
end
  4 件のコメント
Dawud Adam Rabiu
Dawud Adam Rabiu 2021 年 11 月 10 日
Thank you Awais, can you explain the lines of code please ?
Awais Saeed
Awais Saeed 2021 年 11 月 10 日
I have added some comments. For better understanding use debug mode.

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

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