Code using MATLAB
Use recursion only
4. Palindrome
A palindrome is a string that reads the same forwards and backwards. For example, "abcdedcba" and "abccba" are both palindromes, but "abcdefdcba" is not. This can be tested for in a natural way using recursion, and you will explore it here.
Main Function:
Input variables: a string (vector of characters)
Output variables: a logical value which is true if the given string is a palindrome and false otherwise
is_palindrome Function:
Input variables: a string (vector of characters)
Output variables: a logical value which is true if the given string is a palindrome and false otherwise
A possible sample case is:
>> [ret_val] = is_palindrome('abcdedcba')
ret_val = 1
>> [ret_val] = is_palindrome('abcdefdcba')
ret_val = 0