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!