Question
Matlab code Function Name: celery Inputs: 1. ( char ) The name of a text file, including file extension Outputs: None File Outputs: 1. A
Matlab code
Function Name: celery
Inputs:
1. ( char ) The name of a text file, including file extension
Outputs:
None
File Outputs:
1. A formatted text file containing information about the initial text file
Banned Functions:
unique()
Background:
You recently started writing up some of your favorite short stories and scripts on your computer, but since you have started working with celerys *cough cough* I mean cell arrays in MATLAB, they have been corrupted! Oh no! Now, you must embark on an epic quest to use the very same piece of software that corrupted your files to analyze your files.
Function Description:
You will be given a text file. Extract every unique word and count the number of times each unique word appears in the text file. Case should be ignored when looking for unique words, and any characters that are not letters or spaces should be removed. The words should appear in decreasing order of how often they appeared in the text file. If there is a tie, you should sort the ties alphabetically. To make the output text file, follow these rules:
The output text file should have the name
The output file should start with 'A counting of the story
The second line should read 'The number of times celery was seen: celery>' . The third line should read 'All other words:' . The rest of the file should list the unique words in the following form: ' times>' . Each word should be lowercase. Put each word on a new line. Do not include the word "celery" in this section. Example: Notes : There should NOT be a newline character at the end of your text file. All the words in the text file should be lowercase. Hints : sort() preserves the original order of duplicated elements. In order to sort by two things, think about how you could use the sort() function twice. twinkle.txt: twiNk)(le twinKLe# li,ttle celery H34ow i ce//lery wh*at you are
twinkle_counted.txt: A counting of the story twinkle: The number of times celery was seen: 2 All other words: twinkle: 2 are: 1 how: 1 i: 1 little: 1 what: 1 you: 1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started