Help Converting text to morse code

2 vues (au cours des 30 derniers jours)
Christopher
Christopher le 12 Déc 2013
Commenté : Matt Kindig le 12 Déc 2013
Hey Guys,
I am really struggling with this problem for my MATLAB class The teacher asks:
In this project, you will write a program to translate the Morse code of text messages back into plain texts. For simplicity, your program only processes the Morse code for text messages consists of only letters and digits. For example, the Morse code '-- .- - .-.. .- -... / .--. .-. --- --. .-. .- -- -- .. -. --.' will be translated into 'MATLAB PROGRAMMING'. Because Morse code is case insensitive, it is also correct translation if some or all of the letters in the resulting plain text are in lowercases.
At the beginning part the program, you may copy and reuse the following code snippet to define the mapping between letters/digits and their Morse code. Please note that, in the following code, Num1, Num2,..., A, B, ..., Z, etc, are variable names. You should not append them into the plain text (e.g. plain_text = [plain_text A]). Instead, you should add to the plain text the corresponding letters or digits (e.g. plain_text = [plain_text 'A']).
Num1='.----'; Num2='..---'; Num3='...--'; Num4='....-'; Num5='.....'; Num6='-....'; Num7='--...'; Num8='---..'; Num9='----.'; Num0='-----'; A='.-'; B='-...'; C='-.-.'; D='-..'; E='.'; F='..-.'; G='--.'; H='....'; I='..'; J='.---'; K='-.-'; L='.-..'; M='--'; N='-.'; O='---'; P='.--.'; Q='--.-'; R='.-.'; S='...'; T='-'; U='..-'; V='...-'; W='.--'; X='-..-'; Y='-.--'; Z='--..'; In your program, use input function to allow users to type in Morse code. Your program accepts the code as a string. For each Morse code segment separated by space in the string, the program finds out the corresponding letter or digit and writes it into another string. When a slash is met, a space should be added to the resulting string to separate words. Your program can safely assume that the Morse code is well-formatted. There is only one space between the Morse code segments for consecutive letters or digits. The separator of consecutive words is ' / ' (space-slash-space). Ill-formatted Morse code is considered to be illegal.
  1 commentaire
Matt Kindig
Matt Kindig le 12 Déc 2013
Sounds straightforward enough. What exactly is your difficulty?
Note that this forum won't do your homework for you, but we are happy to assist with a specific question in Matlab. That requires you to show us some code, so that we can see that you put in effort to do the assignment.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Environment and Settings dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by