Replace certain row values in a cell based on a condition
Mostrar comentarios más antiguos
I have a 1600x1 cell, where every row contains one of two strings - A or B.
I am trying to replace them with doubles (A with 0, B with 1), but having some difficulties. The '==' operator does not work because it is a cell. My attempts to convert it to a vector (via cell2mat) failed with the very peculiar:
Error using cat
Dimensions of arrays being concatenated are not consistent.
Error in cell2mat (line 83)
m{n} = cat(1,c{:,n});
Error in my_file (line 149)
col = cell2mat(col)
My questions are two (of which only the first is important, second is merely curiosity):
1 - How do I replace the A and B strings in my 1600x1 cell with 0 and 1 respectively?
2 - Why does cell2mat fail when attempting to convert a Nx1 cell?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Cell Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!