Question: In matlab Write a function ispalindrome that returns whether a given input string is a palindrome and also its reversal (strip out any non-alphabetical characters).
In matlab
Write a function ispalindrome that returns whether a given input string is a palindrome and also its reversal (strip out any non-alphabetical characters). A palindrome is a string that is the same as its reverse. e.g., "Was it a car or a cat I saw?!" is a palindrome because you get the same string when you reverse the order of the characters. The first thing you do with the input is to strip out any non-alphabetical characters and convert any upper case letters to lower case. So, "Was it a car or a cat I saw?!" will become "wasitacaroracatisaw".
Example:
>> [ispal,rev]=ispalindrome('Was it a car or a cat I saw?!') ispal = logical 1 rev = 'wasitacaroracatisaw' >> [ispal,rev]=ispalindrome('Fool proof!') ispal = logical 0 rev = 'foorploof'
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
