delete row from cell array under specific conditions
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hi, sorry for the question, but I'm new at programming in Matlab.
I have a Cell Array, let's say CellArray, and I want to delete the rows where (the element in the first column is equal to a specified number) and (the element in the third column is equal to a string, for istance 'up') how do I do it? I think with cellfun I should be able to do it in only one line of code, but I don't know how.
0 comentarios
Respuestas (1)
Von Duesenberg
el 10 de Mzo. de 2018
Here's a quick made up example (if you can convert your cell to a table with cell2table); of course, it would have been easier if you had provided your actual data:
newT = table([1; 2; 3], {'is'; 'is'; 'is'}, {'up'; 'up'; 'down'})
newT(~strcmp('1', newT.Var1) & ~strcmp('up', newT.Var3),:)
2 comentarios
Luca Zinicola
el 10 de Mzo. de 2018
Editada: Luca Zinicola
el 10 de Mzo. de 2018
Von Duesenberg
el 10 de Mzo. de 2018
I'm pretty sure somebody will come up with the right solution, but you can always use mine: convert your cell to table, delete the relevant rows, and convert the table back to cell (with table2cell)...
Ver también
Categorías
Más información sobre Cell Arrays en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!