Add multiple rows of a matrix in one row.
9 次查看(过去 30 天)
显示 更早的评论
I have a matrix with 'n' rows and 3 columns. I want to add all the rows and at the end generate a 1x3 matrix. I want all the elements of the 1st column to add up, 2nd column elements to add with eachother and, and the elements of the 3rd column to add up.
Kindly guide me regarding this. Thank You.
0 个评论
采纳的回答
the cyclist
2023-9-26
编辑:the cyclist
2023-9-26
% Create an input matrix like yours
n = 4;
M = rand(n,3)
% Calculate the sum
sumM = sum(M)
As you may realize, this is a very basic MATLAB question. You would likely benefit from the free online MATLAB Onramp tutorial.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!