Filter löschen
Filter löschen

function that gives the number of letters in a word

1 Ansicht (letzte 30 Tage)
Lee
Lee am 30 Apr. 2013
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

Antworten (2)

Andrei Bobrov
Andrei Bobrov am 30 Apr. 2013
length(w{1}) ;
out = cellfun('length',w);
  2 Kommentare
Jan
Jan am 30 Apr. 2013
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.

Melden Sie sich an, um zu kommentieren.


Walter Roberson
Walter Roberson am 30 Apr. 2013

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by