Write a function that takes as input a character array

Assignment Help MATLAB Programming
Reference no: EM132094138

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

Reference no: EM132094138

Questions Cloud

A program that will search a file of numbers of type int : Write a program that will search a file of numbers of type int and write the largest and the smallest numbers to the screen.
Healthcare quality comparison websites : Using publicly available data from one of the two healthcare quality comparison websites listed below, select and compare three healthcare providers
Part of the culture production system : Give specific examples of how Slumdog Millionaire is part of the culture production system?
Strategic change at nokia : Based in Finland, Nokia transformed from being a diverse conglomerate into a world-leading mobile phone producer in the 1990s. Since then
Write a function that takes as input a character array : Write a function called reverseWordOrder.m that takes as input a character array (a string) and returns the same string with the words reversed
Write a java class called point that corresponds : Write a java class, called Point that corresponds to the definition of a point in the 2D plane.
Collection of carpet could be proprietary or industrywide : Carpet recycling has following supply chain options: a) Collection of carpet could be proprietary or Industrywide b) Processing could be in original factory
Highlight the main topics of the presentation : a) Please, watch the video found in the link below and highlight the main topics of the presentation
Types of content before the public : What do you believe is the media's responsibility when putting certain types of content before the public?

Reviews

len2094138

8/23/2018 5:24:02 AM

Instructions: this homework has 3 questions. For each question, you will create a separate function file. Upload ALL files as your submission on CCLE. They should run. There are four extra credit problems for this assignment worth a total of 3 points. Note: For these problems, you do not have to worry about checking for different kinds of input unless explicitly indicated by the problem. Assume benevolent users who are giving you the input you expect.

len2094138

8/23/2018 5:23:57 AM

Hint: there is a long way to do this using a loop, which is fine, but it’s actually possible to do this entire function in a single line of code (although several functions are called in that one line)! You may need to do a little bit of Googling / using help or lookfor or doc to find functions that can do what you need. A lot of useful functions begin with “str” and “is”

len2094138

8/23/2018 5:23:51 AM

Note: the output might actually look like {[1x2 double], [1x2 double], []} which is ok. You can test out your code with the wordTestArray.mat array that I provided on CCLE. It is a 15x15 grid with a bunch of words. It contains 13 words that are 4 or more letters long. Hint: some of the functions that we learned in class will not work on the entire array all at once. You may have to use a loop to look through each row and each column of the array.

Write a Review

MATLAB Programming Questions & Answers

  Finite difference method

Use the finite difference method to calculate the temperature at the point specified since it is easier.

  Determine the necessary shell temperature

In a shell-and-tube heat exchanger, one fluid passes through a central tube while another fluid flows through an outer shell in the opposite direction. The purpose is to heat the fluid passing through the central tube.

  Find the integral of a function at an arbitrary location

Write a Matlab function to perform numerical integration of a set of evenly spaced data points using the trapezoidal rule

  Compute the speed of single-stage planetary gear train

Write a MATLAB function [speed] = planetary (N, emesh, first, last, arm) that computes the speed of a given link in a single-stage planetary gear train.

  Calculate and plot the error in the numerical derivative

Write a program to calculate and plot the error in the numerical estimate of the derivative.

  Create the graph using matlab functions

Create the graph, which contains a piecewise function where a line exists in the first interval, a parabola in the second interval, and the sine function in the third interval.

  Develop a simulation program

Develop a simulation program

  Create a vector in matlab

Create a three dimensional diagram of function.

  Open a named pipe and to read data from the pipe

Open a named pipe and to read data from the pipe in matlab

  Write the commands that will create the matrix

Write the commands that will create the matrix.

  Lagrange interpolating polynomial of degree

Lagrange interpolating polynomial of degree

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd