Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(In MatLab) Write a function RevertString.m that accepts a string as its argumen

ID: 671118 • Letter: #

Question

(In MatLab)

Write a function RevertString.m that accepts a string as its argument and returns a string that’s areverted version of that string (string obtained by flipping the argument string i.e. making the lastcharacter of the argument string first in the output string, second to last character of the argumentstring should become the second character of the output string and so on, with your last character ofthe output string being the first character of the argument string).

For example

A=RevertString(‘Okay’)should give you a string A that is equal to ‘yakO”

or

B=RevertString(‘Hello’)should give you a string B that is equal to ‘olleH’.

Explanation / Answer

A built-in function, "fliplr(string)" handles reversing a string of ASCII characters. Unicode is a whole other beast, if you need this functionality test to see if "fliplr()" properly handles the unicode characters you use. If it doesn't then you will need to code a function that is specific to your application. >> str = 'xyz'; >> fliplr(str) ans = zyx