function that gives the number of letters in a word

1 回表示 (過去 30 日間)
Lee
Lee 2013 年 4 月 30 日
for example abcd should be equal 4 when i define a vector w={'abcd','ccb'} length(w(1,1)) gives me 1 and not 4

回答 (2 件)

Andrei Bobrov
Andrei Bobrov 2013 年 4 月 30 日
length(w{1}) ;
out = cellfun('length',w);
  2 件のコメント
Jan
Jan 2013 年 4 月 30 日
w(1,1) is : {'abcd'}, a {1x1} cell and therefore its length is 1. But you want the contents of this cell element, and therefore nedd the curly braces, as Andrei has shown.
Image Analyst
Image Analyst 2013 年 4 月 30 日

サインインしてコメントする。


Walter Roberson
Walter Roberson 2013 年 4 月 30 日

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by