Using the MathWorks product Matlab R2014b to solve math problems is fast and easy. Matlab was designed for all sorts of mathematical computations, including engineering, controlling systems, communications, signal processing, financial modeling and data analysis. In Matlab, data manipulation is performed with matrices. One of the basic matrix operations you must master before moving on to complex computations is how to find the sum of a row.
How to Sum a Matrix Row in Matlab
Define the matrix whose rows you want to sum. Type
A = [1 2 3; 4 5 6; 7 8 9]
in the Command Window and type "A" without the quotations in the command line to define the following example matrix.
1 2 3
4 5 6
7 8 9
Select the equation "S = sum(A,dim)" from the Matlab library. In this equation, "dim" stands for the dimension you want to sum. It must be a positive integer scalar.
Type the summation equation into the command line. Use "2" for the "dim" value to sum rows.
S = sum(A,2)
For our example matrix, this is the result of the summation equation.
Tips & Warnings
- If you change the "dim" value to 1, i.e., S = sum(A,1), you will get the sum of the columns instead of the rows.
- Do not forget to enter a value for "dim"; otherwise you will get a sum of the columns by default.
- Photo Credit George Doyle/Stockbyte/Getty Images
How to Find the MATLAB Number of Rows
MATLAB is a technical computing program used in the scientific and engineering community, which require automated and efficient data handling and processing...
How to Output MATLAB Results
MATLAB (Matrix Laboratory) is a very powerful package of mathematical matrix manipulation software tools, as well as a high-level programming language and...