Deleting rows in a cell array based on a specific value in a column
显示 更早的评论
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'.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!