Problem 394. Convert String to Morse Code
Convert a given string to international Morse Code
- Strings will only have [A-z], [0-9] and space characters
- A string must be returned with dots (.), dashes (-) and spaces between words
For example: given str = 'MATLAB is good' return ystr = '--.--.-...--... ..... --.-------..'
Solution Stats
Problem Comments
-
1 Comment
replace table for who need
symbol = {'A' 'N' 'B' 'O' 'C' 'P' 'D' 'Q' 'E' 'R' 'F' 'S' 'G' 'T' 'H' 'U' 'I' 'V' 'J' 'W' 'K' 'X' 'L' 'Y' 'M' 'Z' '1' '6' '2' '7' '3' '8' '4' '9' '5' '0' };
morse = {'.-' '-.' '-...' '---' '-.-.' '.--.' '-..' '--.-' '.' '.-.' '..-.' '...' '--.' '-' '....' '..-' '..' '...-' '.---' '.--' '-.-' '-..-' '.-..' '-.--' '--' '--..' '.----' '-....' '..---' '--...' '...--' '---..' '....-' '----.' '.....' '-----' };
symbol{k} ---> morse{k}
Solution Comments
Show commentsProblem Recent Solvers208
Suggested Problems
-
2502 Solvers
-
2247 Solvers
-
Solve the set of simultaneous linear equations
420 Solvers
-
Make a random, non-repeating vector.
9272 Solvers
-
Remove the two elements next to NaN value
651 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!