Generating a vector containing the sizes of all cells of a cell array, along a specific dimension
3 次查看(过去 30 天)
显示 更早的评论
Is there a way to vectorize this? (I tried with "cellfun", but did not succeed).
for i = 1:numel(a)
s(i) = size(a{i}, 1);
end
Where a sample of "a" is provided in attachment.
2 个评论
the cyclist
2017-1-25
编辑:the cyclist
2017-1-25
It would be much easier to help if you posted code that actually creates a small example of a, rather than pseudocode that illustrates what you mean.
Is
AGA
AGA
meant to represent a 2x3 character array? So, is it correct that
a{1,1} = ['AGA';'AGA'];
would be an example of one element? It seems like that's what you mean, but wanted to be sure.
采纳的回答
the cyclist
2017-1-25
编辑:the cyclist
2017-1-25
Does this give what you want?
s = cellfun(@(x)size(x,1),a);
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!