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
-
Arrange Vector in descending order
11277 Solvers
-
265 Solvers
-
We love vectorized solutions. Problem 1 : remove the row average.
824 Solvers
-
9740 Solvers
-
368 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!