Your code is expecting userInput(i) to be an entire group of pulses. But it is not. userInput is a character vector and (i) is indexing individual characters.
You have three choices:
1. remove the 's' option from input() and require that the user enter in the form
["..-","-"]
with your program crashing if they make a mistake; or
1b) same but put in a try/catch to handle the inevitable errors more smoothly; or
2. Leave in the 's' but expect the user to use the above form but scan the character vector to ensure that it has the right format, and use eval() on the validated character vector;
3. Leave in the 's' and continue to expect the user to use / to mark the end of blocks, and split the character vector into pieces at each / and string() the cell array of character vectors you got from the splitting to create the string array that you can use (i) indexing with.
