compare length of arrays in a cell
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
ludvikjahn
el 12 de Mzo. de 2015
Comentada: Adam
el 13 de Mzo. de 2015
good morning, I have acell array and i want to compare cell's length. Till now I used just t compare the equality of the cells using:
isequal(A{1,:})
A is the cell array.
I tried to run
isequal(length(A{1,:}))
but that's not correct.
What is the easiest way to achieve that, without using a or cycle???
Thanks
Respuesta aceptada
Más respuestas (1)
per isakson
el 12 de Mzo. de 2015
Editada: per isakson
el 12 de Mzo. de 2015
A hint based on some guessing
cac = {'abc','def', 'ghi'};
tmp = cellfun( @length, cac, 'uni', false );
isequal( tmp{:} )
returns
ans =
1
I failed to make a one-liner
 
Addendum
A variant more in line with the comments to the question
cac = {'abc','def', 'ghi'};
cac = { cac, cac, cac };
tmp = cellfun( @length, cac, 'uni', false );
isequal( tmp{:} )
returns
ans =
1
Ver también
Categorías
Más información sobre Cell Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!