Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

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

Prepare a 3 - 10 pages long reportprepare a presentation

Prepare a 3 - 10 pages long report Prepare a presentation with 5 - 9 slides. The slides will include introduction (need and similar work), theoretical background (tested neural networks), Data, Results (Comparison of the ...

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.

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 ...

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 ...

Assignmentafter the success of your robo-advice venture you

Assignment After the success of your robo-advice venture you decide to explore alternative sources of profitability for your company. You realize that Australian investors are often forced to chose between expensive acti ...

Suppose that you have used some concept learning algorithm

Suppose that you have used some concept learning algorithm to learn a hypothesis h1 from some training data. You are interested in knowing the accuracy that the hypothesis can be expected to achieve on the underlying pop ...

Recitation problems -1 determine the highest real root of

Recitation Problems - 1. Determine the highest real root of f(x) = 2x 3 - 11.7x 2 + 17.7x - 5 using the Newton-Raphson method with at least four iterations. Start with an initial guess of x 0 = 3. 2. Determine the real r ...

Assignmentq1 find the laplace transforms of the following

Assignment Q.1 Find the Laplace transforms of the following functions: (a) t 2 + at + b and (b) sin(2nΠt/T) Q.2 Find f (t) for the following F(s) = α[ f (t)]. (i) 5/(s + 3), (ii) 1/s 2 + 25, (iii) 1/s(s+1) Q.3 Find the L ...

What comparison of means test was used to answer the

What comparison of means test was used to answer the question

Suppose that a student has the option of enrolling for a

Suppose that a student has the option of enrolling for a single elective during a term. The student must select a course from a limited list of options: "English, " "History, " "Biology, " "Computer, " or "Math." Constru ...

  • 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