MATLAB: How to remove repeating rows without unique function

MATLABmatrixmatrix manipulationsimulink

I have a 624×2 matrix of ordered pairs, of which there are some repeating rows that I must remove. Is there a way to remove these repeating rows without using the unique function? Maybe using a for loop? The reason I can't use the unique function is because when I implement this matlab script in Simulink's Matlab Function block, the matrix must be sorted first before using the unique function. I can't sort the matrix because I will lose my ordered pairs and sortrows doesn't solve the issue either because I get the same error from Simulink.

Best Answer

Use the 'stable' option:
>> A = randi( 3, 10, 2 )
A =
2 3
1 1
3 1
3 1
3 1
3 3
3 3
2 1
2 3
1 1
>> unique( A, 'rows' )
ans =
1 1
2 1
2 3
3 1
3 3
>> unique( A, 'rows', 'stable' )
ans =
2 3
1 1
3 1
3 3
2 1