MATLAB Answers

Sum of a row

93 views (last 30 days)
Farah Shahpoor
Farah Shahpoor on 10 Apr 2019
Answered: Guillaume on 10 Apr 2019
Hello,
I have a Matrix 3x30 and I want to have the sum of the first row (element 1 to 30)
Can anyone help me? I just find solutions for sum of a vector or a matrix but I want to have each row seperately.
Thx in advance

  0 Comments

Sign in to comment.

Answers (1)

Guillaume
Guillaume on 10 Apr 2019
sum(yourmatrix, 2)
will give you the sum of each row as 3x1 vector.
sum(yourmatrix(1, :))
will give you the sum of just the first row. (or just take the first element of the previous result)

  0 Comments

Sign in to comment.

Sign in to answer this question.

Tags