Adding multiple rows of a cell array
显示 更早的评论
Hello, I have a 5x1 cell array, in which each cell is a 6x64 double.

For each cell, I want to add the rows in this style,

1st, 3rd and 5th rows addded together to make one row
2nd 4th and 6th row added together to make one row.
Can it be done without loop?
I am attaching the file . I don't have any code written yet, because I dont know how to do it..
Does anybody know?
采纳的回答
更多回答(1 个)
madhan ravi
2020-7-12
编辑:madhan ravi
2020-7-12
Edit: cellfun() is a loop in disguise by the way.
for k = 1:numel(cell_array)
cell_array{k}(end+1,:) = sum(cell_array{k}(1:2:5,:));
cell_array{k}(end+1,:) = sum(cell_array{k}(2:2:6,:));
end
类别
在 帮助中心 和 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!