How to average in rows of two numbers
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Lokeswara reddy pamulapate
am 7 Mär. 2020
Kommentiert: Star Strider
am 8 Mär. 2020
Hi all,
I have a matrix of 1*305, I want to take the average of two rows like (1st row to 4th row) and (2nd row to 5th row) and (3rd row to 6th row) and (7th row to 10th row) and (8th row to 11th row) and (9th row to 12 row) and soo on. I want to take average in this way, can anyone help me out.
Thankyou
0 Kommentare
Akzeptierte Antwort
Star Strider
am 7 Mär. 2020
If I understand correctly what you want to do, this will work:
D = load('AI_Aorta.mat');
x = D.x;
idx = hankel(1:4, 4:numel(x)); % Index Matrix
xm = mean(x(idx)); % Mean Of Columns Of Resulting Matrix
To understand what this code does and how it works:
Check_First_Five_Columns = x(idx(:,1:5)) % The 'xm' Variable Is The Mean Of The Columns Of This Matrix (Extended To 302 Columns)
producing:
Check_First_Five_Columns =
0.1247 0.2370 0.1695 0.2010 0.2228
0.2370 0.1695 0.2010 0.2228 0.1482
0.1695 0.2010 0.2228 0.1482 0.1683
0.2010 0.2228 0.1482 0.1683 0.2063
4 Kommentare
Star Strider
am 8 Mär. 2020
I am lost.
xm = filter([1 0 0 1], 2, x(1:153)); % Column Mean
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!