While you want to understand the issue of how to use strcmp, a better test is to not do so at all!
So you might use strcmpi, which does a case insensitive test instead.
Better and simpler yet? Use ismember.
if ismember(lower(x), {'black' 'brown' 'orange'})
Do you really want to understand why your code using strcmp failed? Sigh. :)
x = 'Black'
x =
'Black'
x = lower(x)
x =
'black'
strcmp(x,'Black')
ans =
logical
0
Of course they are not the same. You converted the input to all lower case. But then you compared x to an upper case color name.
That is why strcmpi helps.
x
x =
'black'
strcmpi(x,'Black')
ans =
logical
1
But still, USE ISMEMBER.