how can i do that for all columns?
3 ビュー (過去 30 日間)
古いコメントを表示
hi , i have a matrix (length(a),length(b)) and i want to write a function that calculates the sum of all a in a column. how can i do that for all columns?
0 件のコメント
回答 (1 件)
Suraj Mankulangara
2018 年 3 月 13 日
Hi Ach
The "sum" function in MATLAB returns the total of all elements in a column (or row) of a matrix. For more information on how to use the sum function, you can refer to the link below:
https://in.mathworks.com/help/matlab/ref/sum.html
By default, the "sum" function computes column-wise total of elements in a matrix, so in your case,
sum(matrix)
should get you the result that you want.
参考
カテゴリ
Help Center および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!