matlab单元格数组中每个元素的长度 [英] matlab length of each element in cell array
本文介绍了matlab单元格数组中每个元素的长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
a={'a','aa','aaa','aaaa'}
length(a)
4
size(a)
1 4
如何使用单个命令获取单元格数组中每个元素的长度?在上面的示例中,所需的输出为[1 2 3 4]
.
How can I get the length of each element in the cell array with a single command? The desired output in the above example would be [1 2 3 4]
.
推荐答案
cellfun('length',a)
将length(x)
应用于a
中的每个元素x
".
"apply length(x)
to each element x
in a
".
这篇关于matlab单元格数组中每个元素的长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文