Averaging rows with rows previous
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
WBOZ11
am 21 Feb. 2018
Kommentiert: WBOZ11
am 22 Feb. 2018
I have data in a matrix where I need each consecutive row to be the average of all the rows above this. How would I go about this?
0 Kommentare
Akzeptierte Antwort
James Tursa
am 21 Feb. 2018
Bearbeitet: James Tursa
am 21 Feb. 2018
Assuming the average includes the row in question:
x = your matrix
result = cumsum(x)./(1:size(x,1))';
Or for earlier versions of MATLAB:
result = bsxfun(@rdivide,cumsum(x),(1:size(x,1))');
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical 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!