Ask MATLAB Expert

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

MATLAB, Engineering

  • Category:- MATLAB
  • Reference No.:- M93081609
  • Price:- $35

Priced at Now at $35, Verified Solution

Have any Question?


Related Questions in MATLAB

Assignment - matlab programmingusing appropriate matlab

Assignment - MatLab Programming Using appropriate MatLab syntax, write the code required to analyse and display the data as per the problem description. The order of the MatLab Program should be as follows: Variables and ...

Assignment details -need to write a code for connecting

Assignment Details - Need to write a code for connecting segments (Lines) a special case of TSP. The problem is to connect lines in 2d/ 3d space with path obstructions. Can you help me write the code for this? Hope you m ...

Assignment -we have daily gridded rainfall data of 40 years

Assignment - We have daily gridded rainfall data of 40 years and structure of the dataset is like below; Lat = [6.5:0.25:38.5]; Lon = [66.5:0.25:100]; Rainfall (135x129x365x40) (Lon, Lat, days, years). Now, we looking fo ...

Question a safe prime is a prime number that can be written

Question : A safe prime is a prime number that can be written in the form 2p + 1 where p is also a prime number. Write a MATLAB script file that finds and displays all safe primes between 1 and 1000.

Question - verify the attached paper with matlab and get

Question - Verify the attached paper with matlab and get all the results in the paper and explain step by step the matlab code. Paper - Improving Massive MIMO Belief Propagation Detector with Deep Neural Network. Attachm ...

Assignment -data is given on which want to do computational

Assignment - Data is given on which want to do computational production planning using Metaheuristic MATLAB Programming: 1) Ant Colony Algorithm on both Partial and Total Flexible Problem. 2) Bee Algorithm on both Partia ...

What comparison of means test was used to answer the

What comparison of means test was used to answer the question

Question 1 manipulate spectral imagehyperspectral images

Question 1. Manipulate spectral image Hyperspectral images can be seen as a generalisation of normal colour images such as RGB images. In a normal RGB colour image, there are 3 channels, i.e. channels for red colour, gre ...

Assignment -matlab codes and simulated model in

Assignment - Matlab codes and simulated model in simulink/matlab and truetime. 1. Matlab codes and simulink model for pid controller optimization using particle swarm optimization (PSO) my plant is integer order 1000/(s^ ...

Assignment matlab programmingusing appropriate matlab

Assignment: MatLab Programming Using appropriate MatLab syntax, write the code required to analyse and display the data as per the problem description. The order of the MatLab Program should be as follows: Variables and ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As