Write a function called reversewordorderm that takes as


Assignment -

Instructions: This assignment has 3 questions. For each question, you will create a separate function file.

Q1. Write a function called reverseWordOrder.m that takes as input a character array (a string) and returns the same string with the words reversed (but not the individual characters!). For example if the input is "I like banana pancakes" the output should be "pancakes banana like I". For this problem, assume (i.e., you don't have to check) that the input is always a string (not a double or a cell) and assume that it has no punctuation. However, if the input is an empty array ([]), the function should also return an empty array or a custom error message that says that the user must provide a string as input to reverse.

Q2. Write a function called Eng2PigLatin.m that takes as input a string in English and converts it to Pig Latin. Here is a summary:

a. If the word begins with a consonant, take all letters before the first vowel (the consonant or the consonant cluster), put them at the end of the word and add "ay" to the end. e.g. snappy → appysnay

b. If the word begins with a vowel, add "way" to the end of the word. e.g. evil → evilway

Assume that the input is a string, but if the input is an empty array the function should also return an empty array or a custom error message that says that the user must provide a string to translate.

Extra Credit 1 - modify your Eng2PigLatin.m function that can take as input an entire sentence (still a character array) and translate every word to Pig Latin.

Extra Credit 2 - write the reverse function, PigLatin2Eng.m that takes as input a word in Pig Latin and converts it into English. Note that while there is only one way to convert an English word into Pig Latin, it can be a little ambiguous about how to go backwards. Pick a rule that makes sense, even if the result isn't necessarily an English word.

Q3. Write a function called WordSearch.m that looks for a word in a 2-D character array. The function should take in two inputs: (1) an m by n character array (letters in the English alphabet) that is the word search grid and (2) a cell array of words that should be searched for. The function looks for each word from the cell array in the 2-D character array. It searches for the word horizontally (left-to-right) and vertically (top-to-bottom). The function then returns a cell array that stores the row and column indices of the first character of the word if the word was found and an empty array ([]) if the word was not found. Your function should ignore the case of the letters. Your function does not need to find words ordered diagonally or backwards (right-to-left or bottom-to-top).

Extra credit 3 - write a second function called WordSearchAll.m that takes as an input just a 2-D character array and automatically finds all English words in the array (either left- to-right or top-to-bottom; don't worry about right-to-left, bottom-to-top, or diagonal words). You can find a list of words in the words.txt file on CCLE. You can read them in as a cell array using the command allWords = importdata('words.txt'); Test it out on wordTestArray.mat. Try to restrict it to only find words that are at least four letters long. It should find thirteen such words. There are several ways that this problem can be solved. Consider different solutions that may take different amounts of time. Try to make your code efficient and leave a comment at the end explaining what steps you took / thoughts you have about efficiency with respect to this problem. Your code should output the list of all of the words that were found. If you are keen on making this program really nice, consider the fact that there are a lot of short words (like 'a', 'to') and some quite bizarre words in the word list. You can make your program nicer by either requiring all found words to have some reasonable minimum length or by comparing the starting indices for all found words, looking at places where multiple words were found for the same index, and selecting only the longest word. You can do another nice thing by capitalizing or otherwise distinguishing the found words in the word array and displaying that as well.

Extra credit 4 - Now that we have a list of English words, we can actually spruce up our PigLatin2Eng function: because there are lots of ways to go from Pig Latin to English, we may end up with non-words. For example: if we started with the word "evil" it became "evilway", but if we wanted to go back to English, we don't know if it should be "evil" or "wevil" since "wevil" would also become "evilway" when converted to Pig Latin. However, "wevil" isn't a real word. Add some checks and rules into the PigLatin2Eng function to take advantage of the fact that some transformations from Pig Latin to English do not produce real words and reject those, instead finding the correct (or at least a more likely) translation. Leave some comments in this function to explain what you did.

Attachment:- Assignment File.rar

Solution Preview :

Prepared by a verified Expert
MATLAB Programming: Write a function called reversewordorderm that takes as
Reference No:- TGS02887595

Now Priced at $35 (50% Discount)

Recommended (93%)

Rated (4.5/5)