Deleting rows in a cell array based on a specific value in a column
Mostrar comentarios más antiguos
Hi, I'm very new to Matlab and struggle with the following code. Any advice would be appreciated.
I have an cell array 7 x 2 cells. I would like to delete any rows when Column 2 contains 0.
A =
7×2 cell array
{[ 0]} {[0]}
{[ 1]} {[0]}
{[ 2]} {[0]}
{[ 3]} {[0]}
{[ 16]} {[1]}
{[ 17]} {[1]}
{[ 18]} {[1]}
Desirable outcome would be
A =
3×2 cell array
{[ 16]} {[1]}
{[ 17]} {[1]}
{[ 18]} {[1]}
I tried the following code but it gave me an error and I don't know how to resolve it. I know the issue is the probably the {} type but I don't know how to fix it.
A(A(:,2) == 0, :) = [];
Operator '==' is not supported for operands of type 'cell'.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Logical 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!