How to average each row from two indivisual comlum vectors?
5 次查看(过去 30 天)
显示 更早的评论
Assume two column vectors with same number of rows:
1 4
2 3
3 2
4 1
I would like to average each row and store this in a new variable hence will be:
2.5
2.5
2.5
2.5
0 个评论
回答(1 个)
Bob Thompson
2021-3-1
A = [1 4;
2 3;
3 2;
4 1];
B = mean(A,2);
2 个评论
Bob Thompson
2021-3-1
If you have 40 rows, aren't you going to end up with 40 results no matter what? Do you not want the average for all individual rows?
As for the two separate vectors, just combine them.
A = [1; 2; 3; 4];
B = [4; 3; 2; 1];
C = [A, B];
D = mean(C,2);
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!