Arrange cell matrix and get the sum
Show older comments
Hi,
"out" cell matrix has 1x365 cells. I have few questions about dealing with cells.
1) I need to delete cells from 361 to 365 in the "out" cell matrix. How can I do that in MATLAB?
2) After deleting, I need to get the sum like this. For example, from cell 1 - 8.
cell1 cell2 .....cell8 sum
0.0 0.1 0.0 0.1
0.0 0.2 0.5 0.7
0.0 0.1 0.1 0.2
.
.
For example,
for ii=1:8:360
sumout=sum(out{1,ii}{1,3});
end
But, this does not give the sum for all rows. Can someone help me?
Thanks in advance.
Accepted Answer
More Answers (1)
the cyclist
on 12 Mar 2015
% Make up some data that seems to be like yours
rng 'default'
out = num2cell(rand(1,365));
% Convert from cell array to numeric
out_numeric = cell2mat(out);
% Trim the unwanted
trimmed_out = out_numeric(1:360);
% Reshape to 45x8
reshaped_out = reshape(trimmed_out,45,8);
% Sum
summed_out = sum(reshaped_out,2);
1 Comment
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





