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
-
Sum all integers from 1 to 2^n
15307 Solvers
-
Back to basics 13 - Input variables
266 Solvers
-
Create a square matrix of multiples
475 Solvers
-
918 Solvers
-
444 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!