MATLAB: Use intersect function in model

simulink

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????

Best Answer

[same,ia,ib] = intersect(a,b,'rows') ;
a(sort(ia),:)