MATLAB: Comparing strings, case insensitive, without str functions

isequalpalindromestrings

I have a project I'm working on for school where we write a Palindrome function. We are supposed to use the "programming method" and write it without using any built-in functions with "str", "eval","flip" or "printf". I have it such that the input word is flipped, and then I was going to compare the strings, but I can't for the life of me figure out what function to use that is not strcmpi to find whether or not the backwards string is equal to the forwards string. It must be case insensitive, so I can't use isequal. Any suggestions?

Best Answer

Do you know how to compare, in a case insensitive way, whether two characters are equal or not? Once you can do that, just put it in a loop to compare your string characters one-by-one. Hint: MATLAB uses the ASCII encoding for characters, so there is a pattern between the lower and upper case alphabet. E.g., consider this:
alphabet = char('a'+(0:25))
ALPHABET = char('A'+(0:25))
double(alphabet)
double(ALPHABET)
alphabet - ALPHABET
You can use the results of this code to come up with a scheme for comparing when two characters are the same in a case insensitive way.
Related Question