【问题标题】:Removing rows by index from arrays in matlab [duplicate]从matlab中的数组中按索引删除行[重复]
【发布时间】:2021-11-06 22:47:27
【问题描述】:

我有一个 2500*30 元素的数组(它的类型是“单”),我需要删除几行我知道索引的行。例如:

duplicate_ids = [1,4:8,11,859,866,1673,2157,2187,2188,2194,2195];

我该怎么做?我的偏好是不写 for 循环,因为我可能会犯错(删除前一行时,下一行的索引会在每次旋转时改变)。

提前致谢

【问题讨论】:

    标签: arrays matlab loops multidimensional-array row


    【解决方案1】:

    很遗憾,我目前没有有效的许可证,因此我无法对其进行测试以确保它可以正常工作,但基于documentation on row-removal,我相信您可以这样做:

    mat(duplicate_ids, :) = [];
    

    【讨论】:

      猜你喜欢
      • 2015-07-27
      • 1970-01-01
      • 1970-01-01
      • 2010-12-19
      • 1970-01-01
      • 2012-02-12
      • 2018-05-07
      • 1970-01-01
      相关资源
      最近更新 更多