Our World Statistics Day conversations have been a great reminder of how much statistics can inform our lives. Do you have an example of how statistics has made a difference in your life? Share your story with the Community!
Choose Language Hide Translation Bar

Compute Row Sums of a Matrix

Problem

You have a matrix stored in JSL, and you would like to create a column vector that contains the sums of each row of values in the matrix.

Solution

Use a combination of the V Sum() function and matrix transposes:


M = [1 2 3, 4 5 6, 7 8 9];
V = V Sum( M` )`;
Show( V );

The above script results in the following output in the Log window:

Show( V );
/*:

V = [6, 15, 24];

 

Discussion

 

See Also

 

Article Labels

    There are no labels assigned to this post.

Article Tags
Contributors