How to create a program that compares outputs in dictionary lexicographic
2 ビュー (過去 30 日間)
古いコメントを表示
a function B=compare(s,t) that outputs "1" if s<=t in dictionary lexicographic ordering, and "0" if s>t in dictionary lexicographic ordering so that you can use it in IF statements.
0 件のコメント
回答 (1 件)
CARLOS RIASCOS
2018 年 4 月 4 日
Hi, try this function, it worked for me !, look how I use it in the image:
function tlex = compare(int1,int2)
Lex = ['a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q'...
'r' 's' 't' 'u' 'v' 'w' 'x' 'y' 'z'];
Lex_value=1:length(Lex);
a=find(Lex == int1);
b=find(Lex == int2);
if Lex_value(a) > Lex_value(b)
tlex=0;
elseif Lex_value(a)<= Lex_value(b)
tlex=1;
end
end
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Migrate GUIDE Apps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!