How to average in rows of two numbers
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Lokeswara reddy pamulapate
le 7 Mar 2020
Commenté : Star Strider
le 8 Mar 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![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/275748/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/275748/image.jpeg)
0 commentaires
Réponse acceptée
Star Strider
le 7 Mar 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 commentaires
Star Strider
le 8 Mar 2020
I am lost.
xm = filter([1 0 0 1], 2, x(1:153)); % Column Mean
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!