byRow
Syntax
byRow(func, X)
Arguments
func is either a vector function (both input and output are vectors of equal length) or an aggregate function.
X is a matrix.
For the arguments and calculation rules of other row-based functions, refer to Row-Based Functions.
Details
Apply the specified function to each row of a matrix.
Examples
m=matrix(1 1, 2 3, 2 1);
m;
col1 | col2 | col3 |
---|---|---|
1 | 2 | 2 |
1 | 3 | 1 |
byRow(add{10 20 30},m);
col1 | col2 | col3 |
---|---|---|
11 | 22 | 32 |
11 | 23 | 31 |
byRow(mode,m);
// output
[2,1]
Related function: byColumn