How to remove the rows with particular value in a cell?

1 visualización (últimos 30 días)
Akhil  Reddy
Akhil Reddy el 7 de Jun. de 2016
Comentada: Jos (10584) el 20 de Abr. de 2017
A = { a 99 8.5; b 2.4 9.7; c 12 99; d 13 11; e 1 1; f 0 1}
I would like to remove the rows with 0 and 99. i.e Row 1, Row 3 and Row 6

Respuesta aceptada

Jos (10584)
Jos (10584) el 7 de Jun. de 2016
a = 'unknown', b = [], c = 1, d= 1:10, e ={'cell_in_cell'}, f.x = 'struct'
A = { a 99 8.5; b 2.4 9.7; c 12 99; d 13 11; e 1 1; f 0 1}
B = A(~any(cellfun(@(x) isequal(x,0) || isequal(x,99),A,'un',1),2),:)
  2 comentarios
JFz
JFz el 6 de Abr. de 2017
Hi, Jos,
Thanks for the answer here. But what is the use of 'un' and 1 here in this line: B = A(~any(cellfun(@(x) isequal(x,0) isequal(x,99),A,'un',1),2),:) Thanks!
Jos (10584)
Jos (10584) el 20 de Abr. de 2017
"un" is short for "UniformOutput" (see the help of cellfun for details). Matlab often allows for shortening inputs.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Structures 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!

Translated by