Add multiple rows of a matrix in one row.
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Abdul Nafey
am 26 Sep. 2023
Bearbeitet: the cyclist
am 26 Sep. 2023
I have a matrix with 'n' rows and 3 columns. I want to add all the rows and at the end generate a 1x3 matrix. I want all the elements of the 1st column to add up, 2nd column elements to add with eachother and, and the elements of the 3rd column to add up.
Kindly guide me regarding this. Thank You.
0 Kommentare
Akzeptierte Antwort
the cyclist
am 26 Sep. 2023
Bearbeitet: the cyclist
am 26 Sep. 2023
% Create an input matrix like yours
n = 4;
M = rand(n,3)
% Calculate the sum
sumM = sum(M)
As you may realize, this is a very basic MATLAB question. You would likely benefit from the free online MATLAB Onramp tutorial.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!