Here is a task:
You’re given a text file. Your first task is to create a variable in MATLAB which will hold the text given to you. You want to know: a. How many letters are present in this text? b. How many “e”s are present in the text? c. What percentage of the text do they correspond to? d. How many words are there in the text given to you? (Hint: Count the number of spaces.)
Write a function textCount1 that takes as a parameter a string which is the name of the text file. For example, if you wanted to do this analysis on a file named data.txt in your working directory, you would invoke textCount1('data.txt').
The result of the function should be a vector consisting of the number of e's and the number of words. Cody will supply the test file which will be the parameter for your function.
MATLAB and Simulink resources for Arduino, LEGO, and Raspberry PiLearn more
Opportunities for recent engineering grads.Apply Today
New to MATLAB?Learn MATLAB today!
Play games and win prizes!Learn more