Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is for MATLAB class please write the MATLAB code Thanks in advance These are the answers with the test cases. Function Name: magicTreehouse %

This is for MATLAB class

please write the MATLAB code

Thanks in advance

These are the answers with the test cases.

Function Name: magicTreehouse

%

% Test Cases:

% [count1] = magicTreehouse('shortTest.txt', 'this', 'is')

% count1 => 2 2

%

% [count2] = magicTreehouse('mediumTest.txt', 'Fox', 'ugly')

% count2 => 3 2

%

% [count3] = magicTreehouse('longTest.txt', 'Magic', 'and')

% count3 => 2 12

the txt files contents are the below

(shortTest.txt)

this is a testthis is a pretty short test!(as far as tests go)

(mediumTest.txt)

One day while out on a walk, a Tortoise happened upon a hungry Fox looking out across a pond."Hello, Fox!" the Tortoise said, "I know you are hungry,but please do not try to hurt me. If you do, I can simplyhide inside my shell, and you will never get in.""That is true, your shell is very strong" said the Fox."But can you hide from how ugly you look right now?You are so ugly man, it's just disgusting. You smelly oldwrinkly raisin. I'm tired of looking at you."The Tortoise was not prepared for this absolutely savage roast.He got clowned on for read. He really does look like a raisin, too.

(longTest.txt)

Magic Tree House: Adventures with Jack and Annie, perfect for readers who are just beginning chapter books.The first five Magic Tree House Books#1 Dinosaurs Before DarkJack and Annie discover the tree house and, using the magical books there, they travel back to the late Cretaceous period (65 million years ago) where they meet a Pteranodon that saves them from a Tyrannosaurus rex. Jack finds a gold medallion with the letter "M" on it.#2 The Knight at DawnIn England during the Middle Ages, Jack and Annie explore a castle and meet a brave knight.#3 Mummies in the MorningIn Ancient Egypt, Jack and Annie help Queen Hutepi find her missing Book of the Dead.#4 Pirates Past NoonJack and Annie encounter some pirates in the Caribbean Sea and meet Morgan le Fay, who turns out to be the mysterious "M".#5 Night of the NinjasMorgan le Fay is under a spell. Jack and Annie must find four magical objects toreverse the spell, with the help of a mouse named Peanut. In ancient Japan, Jack and Annie encounter ninjas and samurai and get a moonstone.

image text in transcribed

Function Name: magicTreehouse Inputs: 1. (chan The name of a text tile, including tile extension 2. (char) The first word to look for 3. (char) The second word to look for Outputs: (doubie) A 1x2 vector of the the number of times the first and second word appear in the text file, in order 1. Background: In your quest to become a Master Librarian of Time, you can help Jack and Annie look for intormation in books to help them while they time travel in the Magic Treehouse. Jack and Annie are both looking for different words, so you decide to write a MATLAB function that can search for two words at once in a text file Function Description: Given the name of a text fle and two different words to look for, you will write a function to search through the text file and count the number of times both words appear. Then output the number of times the words appear, concatenated as a 1x2 vecton Example: following three lines, a second input of 'love' and a third input o MATLAB Say you were give the name of the text file matlab,txt' and that le contains the The output would be [1,3] MATLAB I love MATLAB:! MATLAB is actually the best Notes: Ignore all punctuation and non-letter characters that aren't spaces. Your search for words in the text file should be case sensitive Words will always be separated by at least one space Hints: The strtok) function will be useful for separating sentences into words. Function Name: magicTreehouse Inputs: 1. (chan The name of a text tile, including tile extension 2. (char) The first word to look for 3. (char) The second word to look for Outputs: (doubie) A 1x2 vector of the the number of times the first and second word appear in the text file, in order 1. Background: In your quest to become a Master Librarian of Time, you can help Jack and Annie look for intormation in books to help them while they time travel in the Magic Treehouse. Jack and Annie are both looking for different words, so you decide to write a MATLAB function that can search for two words at once in a text file Function Description: Given the name of a text fle and two different words to look for, you will write a function to search through the text file and count the number of times both words appear. Then output the number of times the words appear, concatenated as a 1x2 vecton Example: following three lines, a second input of 'love' and a third input o MATLAB Say you were give the name of the text file matlab,txt' and that le contains the The output would be [1,3] MATLAB I love MATLAB:! MATLAB is actually the best Notes: Ignore all punctuation and non-letter characters that aren't spaces. Your search for words in the text file should be case sensitive Words will always be separated by at least one space Hints: The strtok) function will be useful for separating sentences into words

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Objects And Databases International Symposium Sophia Antipolis France June 13 2000 Revised Papers Lncs 1944

Authors: Klaus R. Dittrich ,Giovanna Guerrini ,Isabella Merlo ,Marta Oliva ,M. Elena Rodriguez

2001st Edition

ISBN: 3540416641, 978-3540416647

More Books

Students also viewed these Databases questions