How to create a program that compares outputs in dictionary lexicographic
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
CARLOS RIASCOS
le 4 Avr 2018
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 commentaires
Voir également
Catégories
En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!