Parse string of comparisons into a matrix

Version 1.0 (3,88 KB) von Wei-Rong Chen
This function parses a string of pairwise comparisons into a matrix of graph.
90 Downloads
Aktualisiert 17. Apr 2015

Lizenz anzeigen

This function parses a string of pairwise comparisons into a matrix of graph.
The output matrix is a graph representing the input string of pairwise comparisons.
Example:
The input 'str' is a string containing descriptions of multiple comparisons, separated by 'delimiter'.
str = 'a > b ; c < b ; a > c < b' ; delimiter = ';'; ifSortElement = 1;
[out, elements] = PairwiseCompareString2GraphMatrix(str, delimiter, ifSortElement)
>> out =
0 1 1
0 0 1
0 0 0
, where the output matrix 'out' is a matrix of the truth values for each comparison, such that :
[a>a] [a>b] [a>c]
[b>a] [b>b] [b>c]
[c>a] [c>b] [c>c]
>> elements =
'a' 'b' 'c'
The output 'elements' contains the unique elements
in the input string, corresponding to
the row and column indice of the output matrix 'out'. .
If ' ifSortElement' = 1, then the output elements will be sorted.
If ' ifSortElement' = 0, then the output elements will be ordered as they appear in the input string.

Zitieren als

Wei-Rong Chen (2024). Parse string of comparisons into a matrix (https://www.mathworks.com/matlabcentral/fileexchange/50539-parse-string-of-comparisons-into-a-matrix), MATLAB Central File Exchange. Abgerufen .

Kompatibilität der MATLAB-Version
Erstellt mit R2008a
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS Linux
Kategorien
Mehr zu String Parsing finden Sie in Help Center und MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Veröffentlicht Versionshinweise
1.0