next up previous
Next: About this document ...

ESC 251 HW 27 Due: Nov. 16

Remember to hand in your MATLAB codes and any program output.

a)
(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
a)
the letter 'a'
b)
the letter 'z'
c)
a space
appear in the string
      s = 'There are many spaces in this sentence.'
2)
(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 done.
3)
(1 pts) Use the strrep command to replace all the spaces in the string from Problem 1 with underscores.




2018-11-14