Next: About this document ...
ESC 251 HW 27 Due: Nov. 16
Remember to hand in your MATLAB codes and any program output.
- (5 pts) Write a MATLAB function that will count the number
of times that a given character appears in some input string. You should
do this using an accumulation loop. Test your function by
counting the number of times
appear in the string
- the letter 'a'
- the letter 'z'
- a space
s = 'There are many spaces in this sentence.'
- (2 pts) Repeat Problem 1, but this time use the built in
string functions to do the counting. There are several ways this can be
- (1 pts) Use the strrep command to replace all
the spaces in the string from Problem 1 with underscores.