![]() |
如何删除Matlab矩阵中的某些行?
我有4892行和4列的双打矩阵。
假设在第3列和第4列中有N行具有相同的值(但不一定在第1列和第2列中),我只想在组中保留一行。 一个例子: 1738 1738 8611 8611 1739 1738 8611 8611 1739 1739 8611 8611 我只想在这一排中只留下一行(与哪一行无关)。 我该怎么做呢? 谢谢! [B]回答:[/B] 使用[URL="http://www.mathworks.com/help/techdoc/ref/unique.html"]UNIQUE[/URL] 。默认情况下,这将保留最后一行。 %# array is your 4892-by-4 array %# call 'unique(array(:,3:4),'rows','first') if you want to keep the first row [~,idx] = unique(array(:,3:4),'rows'); %# use sort if you want to preserve the original order of rows trimmedArray = array(sort(idx),:); [url=https://stackoverflow.com/questions/5407848]更多&回答...[/url] |
所有时间均为北京时间。现在的时间是 23:31。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.