Deleting matrix elements efficiently

前端 未结 1 1221
臣服心动
臣服心动 2021-01-26 15:06

I want to efficiently delete a lot of data from the beginning of a matrix of dimension 2*n. The matrix looks like this:

x1 x2
x3 x4
...
...

I

1条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-26 15:32

    One way is to just compare the entire first column in one go and then delete, i.e.

    rows2delete = list{i}(:,1) <= someNumber; %# creates logical array with 1 for deletion
    list{i}(rows2delete,:) = []; %# delete some rows, all corresponding cols
    

    0 讨论(0)
提交回复
热议问题