How to average in rows of two numbers
7 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Star Strider
2020-3-7
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!