cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
See how to use to use Text Explorer to glean valuable information from text data at April 25 webinar.
Choose Language Hide Translation Bar
View Original Published Thread

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

 

JSL Cookbook

If you’re looking for a code snippet or design pattern that performs a common task for your JSL project, the JSL Cookbook is for you.

This knowledge base contains building blocks of JSL code that you can use to reduce the amount of coding you have to do yourself.

It's also a great place to learn from the experts how to use JSL in new ways, with best practices.