how to find average value up to current row in Matrix
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Triveni
am 26 Nov. 2022
Kommentiert: Triveni
am 26 Nov. 2022
I have a matrix A
A =
[ 128 8.4
127 8.7
128 8.3 ]
I want to find average using A(1,1) * A(1,2)/sum(A(1,1)) for first row. And subsequently for next rows considering calculation of previous row.. And I need the values
B = [
128 8.4
255 8.549
383 8.466 ]
Please help me.
0 Kommentare
Akzeptierte Antwort
Bruno Luong
am 26 Nov. 2022
A = [ 128 8.4
127 8.7
128 8.3 ]
A1 = A(:,1);
cs1 = cumsum(A1);
B = [cs1, cumsum(A1.*A(:,2))./cs1]
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!