Reduce one dimension of a array by using sum
显示 更早的评论
Hello,
Can anyone show me how I can reduce one dimension of the following array without using for loops. Thanks!
A=rand(100,100,100);
for ith = 1:100
for jth = 1:100
B(ith,jth) = sum(A(ith,:,jth))
end
end
采纳的回答
更多回答(1 个)
Azzi Abdelmalek
2012-10-19
A=rand(100,100,100);
out=sum(A,3)
类别
在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!