Re: [問題] 去除相同數值已回收

看板MATLAB作者 (楓霧)時間16年前 (2009/06/08 16:24), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/3 (看更多)
這樣有點冗長,不過堪用 data=[1 2 1 4 1 4 6 8 7 5 7 5]; data=data'; savelocation=zeros(length(data),1); uniquedata=unique(data(:,1)); for n=1:length(uniquedata) samelocation=find(data(:,1)==uniquedata(n)); [udata index]=unique(data(samelocation,2)); savelocation(samelocation(index))=1; end deletedata=find(savelocation==0); data(deletedata,:)=[]; 執行結果: data = 1 6 2 8 1 7 4 5 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.118.207.32
文章代碼(AID): #1ABChM59 (MATLAB)
文章代碼(AID): #1ABChM59 (MATLAB)