Average of matrix element
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Supriya Gain
am 8 Aug. 2019
Kommentiert: Jos (10584)
am 8 Aug. 2019
Suppose i have a 4X1 matrix like [a;b;c;d]. Now i want the output as [a;(a+b)/2;(a+b+c)/3;(a+b+c+d)/4].
How to do that?
1 Kommentar
Akzeptierte Antwort
Weitere Antworten (3)
madhan ravi
am 8 Aug. 2019
cumsum(matrix)./(1:numel(matrix)) % where matrix is a column vector
0 Kommentare
Jos (10584)
am 8 Aug. 2019
One easy option
A = [10 20 30 40]
B = cumsum(A) ./ (1:numel(A))
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!