lab08 finding nemo

2 views (last 30 days)
kioko kinyae
kioko kinyae on 23 Oct 2020
Commented: Image Analyst on 23 Oct 2020
You should turn in: 1. A file named Lab08.m, and a screenshot of you running findingNemo() from the command line. Instructions: 1. On Canvas you will find a file named findingNemo.m and another named nemo.txt. The first contains code which will read in strings from nemo.txt, then call Lab08(string) on each line of nemo.txt. Your job is to write Lab08.m. 2. The Lab08 function will take in a string as input and will return an integer n as output. 3. The value of n will be the nth word in the input string, where n is the location of the substring 'Nemo'. a. Please note that you will need to match whole words only, so 'aNemone' and 'Leonard Nemoy' should not be counted b. All strings will end with punctuation, so you do not need to work out the edge case of a string like 'I found Nemo', which could cause significant problems 4. Once the value of n has been determined (hint: count the number of spaces before the index at which you found Nemo), use the statement fprintf('I found Nemo at word %d!\n',n); to print the results. 5. If Nemo is not in the string, instead use the statement fprintf('I couldn''t find Nemo, sorry.\n'); and set n equal to negative one. 6. If Nemo is in the string multiple times, return the location of its first appearance. 7. Please be aware that if your file and function names are not the same as those expected in findingNemo(), or if all three files are not in the same folder, your code will not work correctly. 8. There are multiple ways to approach this problem, but the regular expressions from Lab 07 may be useful here.
  2 Comments
Star Strider
Star Strider on 23 Oct 2020
That appears to be an interesting homework assignment!
Thank you for posting it!
Image Analyst
Image Analyst on 23 Oct 2020
Thanks for the announcement. If you need help, read this link.

Sign in to comment.

Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!