フィルターのクリア

calculations or sum all diagonal elements

1 回表示 (過去 30 日間)
mohammed abdul wadood
mohammed abdul wadood 2018 年 3 月 11 日
hi. to sum all diagonal elements i used
sum(diag(a))
know; if i want to sum first 170 elements or last 80 elements, how can i do this.

採用された回答

Walter Roberson
Walter Roberson 2018 年 3 月 11 日
FirstN = @(V,N) V(1:N);
LastN = @(V,N) V(end-N+1:end);
sum(FirstN(diag(a), 170))
sum(LastN(diag(a), 80))
  1 件のコメント
mohammed abdul wadood
mohammed abdul wadood 2018 年 3 月 11 日
thank sir, thank you so much

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOperating on Diagonal Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by