Use intersect function in model

2 vues (au cours des 30 derniers jours)
galaxy
galaxy le 5 Août 2019
Commenté : galaxy le 8 Août 2019
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????

Réponse acceptée

KSSV
KSSV le 5 Août 2019
[same,ia,ib] = intersect(a,b,'rows') ;
a(sort(ia),:)
  3 commentaires
KSSV
KSSV le 5 Août 2019
It is better to sort indices....
galaxy
galaxy le 8 Août 2019
yes.
I used "sortrows" and it is OK

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Simulink dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by