summation of rows , then columns in matrix

1 回表示 (過去 30 日間)
fathi
fathi 2017 年 4 月 9 日
コメント済み: Star Strider 2017 年 4 月 10 日
If I have the matrix as next: /// F = [ 3 4 5 6 2 2; 4 5 2 6 6;8 4 3 6 7 ; 5 6 3 8 5 ] /// /// I like to make the summation of rows, then columns in matrix separately and put the result in the new matrix. the number elements in new matrix supposed to be 9. as next:/// Sum = [ 20 ,19,13,26,20,20,23,28,27 ]/// Then make a graph to represent this values, as the relation between X , Y. /// Thank you

採用された回答

Star Strider
Star Strider 2017 年 4 月 9 日
This works:
F = [ 3 4 5 6 2 ; 4 5 2 6 6; 8 4 3 6 7 ; 5 6 3 8 5 ];
Fc = sum(F,2);
Fr = sum(F);
Sum = [Fr Fc']
Sum =
20 19 13 26 20 20 23 28 27
Note Row 1 of ‘F’ has an extra 2. The version here is correct., and gives the correct result.
  2 件のコメント
fathi
fathi 2017 年 4 月 10 日
Thank you Mr Star Strider for your reply.It works.
Star Strider
Star Strider 2017 年 4 月 10 日
My pleasure.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by