如何删除重复的行而无需在Matlab中对其进行重新排序 [英] How to delete repeated rows with out re-ordering them in matlab

查看:422
本文介绍了如何删除重复的行而无需在Matlab中对其进行重新排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个单元格数组:

levelx=
      'GO:0016787'    'GO:0006412'    'GO:0030533'
      'GO:0008150'    'GO:0006412'    'GO:0030533'
      'GO:0006810'    'GO:0006412'    'GO:0030533'
      'GO:0016787'    'GO:0006412'    'GO:0030533'
      'GO:0008150'    'GO:0006412'    'GO:0030533'
      'GO:0006810'    'GO:0006412'    'GO:0030533'
      'GO:0016787'    'GO:0006412'    'GO:0030533'
      'GO:0008150'    'GO:0006412'    'GO:0030533'
      'GO:0006810'    'GO:0006412'    'GO:0030533'
      'GO:0016787'    'GO:0006412'    'GO:0030533'

我需要删除重复的行,但不更改整个行的顺序...请注意,我使用代码来查找唯一的行,但它更改了行的顺序:

I need to delete the repeated rows but without changing the order of the whole rows... Note that I used code to find the unique rows but it changes the order of the rows:

[~,idx]=unique(cell2mat(levelx),'rows');
unique_levelx =  levelx(idx,:);

推荐答案

尝试

unique(levelx,'rows','stable')

请注意,在此语句中,我假设levelx是一个数组,因为这就是我设置测试数据的方式.

Note that in this statement I've assumed that levelx is an array because that's how I set up your test data.

这篇关于如何删除重复的行而无需在Matlab中对其进行重新排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆