how to sum up all rows and put the value in a new column next to the last one

Hello I am trying to sum up all the rows in a matrix, and put the sum in a new column just next to the last one in the same matrix. the number of rows is 1340, but the number of columns is random, does anyone have any idea how to make it in matlab?
many thanks!

2 Comments

What have you tried so far? Please look at the documentation:
doc sum
Please use meaningful tags. All questions in a Matlab forum concern "Matlab". Thanks.

Sign in to comment.

 Accepted Answer

A = rand(15, 1340); % Test data
B = [A, sum(A, 2)];
Is this solution surprising to you? If so, please read the "Getting Started" chapters of the documentation, where such fundamental basics are explained exhaustively.

More Answers (0)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Tags

Asked:

on 10 Jan 2013

Community Treasure Hunt

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

Start Hunting!