Parse string of comparisons into a matrix

版本 1.0 (3.9 KB) 作者: Wei-Rong Chen
This function parses a string of pairwise comparisons into a matrix of graph.
90.0 次下载
更新时间 2015/4/17

查看许可证

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.

引用格式

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. 检索来源 .

MATLAB 版本兼容性
创建方式 R2008a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 String Parsing 的更多信息
标签 添加标签

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.0