MATLAB: How to get the summation of every row in 3 columns

summation

I have 3 columns of "gs" values consists of 11 row I want to get "gtotal" for every row at the column 4

Best Answer

The "sum" function allows you to specify the dimension on which to perform the summation. If you want to sum all the values in a row, that's along the second dimension.
gtotal = sum(gs,2);
or
gs = [gs sum(gs,2)];