Use intersect function in model

4 ビュー (過去 30 日間)
galaxy
galaxy 2019 年 8 月 5 日
コメント済み: galaxy 2019 年 8 月 8 日
Dear all,
I need to get same elements of matrix (follow row) same as intersect function such as following:
  1. a = [ 3 0; 3 0; 1 3];
  2. b = [ 3 0; 3 1; 1 3];
  3. [same,~,~] = intersect(a,b,'rows')
  4. > same =
  5. 1 3
  6. 3 0
I used Matlab Function block and put intersect but has error:
The first operand is not sorted in ascending order. Use SORTROWS first
Anyone knows????

採用された回答

KSSV
KSSV 2019 年 8 月 5 日
[same,ia,ib] = intersect(a,b,'rows') ;
a(sort(ia),:)
  3 件のコメント
KSSV
KSSV 2019 年 8 月 5 日
It is better to sort indices....
galaxy
galaxy 2019 年 8 月 8 日
yes.
I used "sortrows" and it is OK

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by