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
-
Find state names that end with the letter A
1175 Solvers
-
2476 Solvers
-
234 Solvers
-
320 Solvers
-
4659 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!