Unique function for rows with switched elements

バージョン 1.0.1 (1.68 KB) 作成者: Sim
Find unique rows in a 2-element matrix, when rows have switched elements. E.g. when row "1 5" and row "5 1" are both present.
ダウンロード: 3
更新 2022/6/9

ライセンスの表示

This Matlab function provides a way to find:
  1. unique 2-element rows, when rows have switched elements ("u"), i.e., for example, both rows "1 5" and "5 1" are present in the input matrix,
  2. rows with switched elements ("s"), and
  3. indices of rows with switched elements ("is").
Note: this function is designed ONLY for 2-column matrices as input.
% Example of usage:
clear all
clc
% input (here, the row "1 2" is repeated as row "2 1" and the the row "1 5" is repeated as row "5 1")
a = [1 2
4 5
5 1
2 1
1 2
5 2
5 1
1 5
2 9
5 1]
% output
[u,s,is] = unique_switch(a)
% command window
>> u =
1 2
1 5
2 9
4 5
5 2
>> s =
2 1
5 1
>> is{:}
ans =
1
4
5
ans =
3
7
8
10

引用

Sim (2024). Unique function for rows with switched elements (https://www.mathworks.com/matlabcentral/fileexchange/112920-unique-function-for-rows-with-switched-elements), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2022a
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
タグ タグを追加

Community Treasure Hunt

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

Start Hunting!
バージョン 公開済み リリース ノート
1.0.1

Updated summary and updated description

1.0.0