
Comparing the first char of a string in a cell
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Shea Barrett
il 27 Nov 2018
Commentato: madhan ravi
il 27 Nov 2018
I have two varaibles p and d
d = {'9S'};
p = {'9D'};
how can I compare just the first char
how would I compare the 9 in d to the 9 is p
0 Commenti
Risposta accettata
KALYAN ACHARJYA
il 27 Nov 2018
Modificato: KALYAN ACHARJYA
il 27 Nov 2018
d={'9S'};
p={'9D'};
result=strncmpi(d,p,1)
if result=1, first character is same, else not same.
Example:
d={'PS'};
p={'QD'};
result=strcmp(d,p,1) %strcmp is case sensitive too
% Thanks @madhan Ravi

Più risposte (0)
Vedere anche
Categorie
Scopri di più su Data Type Conversion in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!