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
-
233 Solvers
-
Back to basics 25 - Valid variable names
324 Solvers
-
Pig Latin to English Translator
154 Solvers
-
715 Solvers
-
654 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!