Help Converting text to morse code

2 Ansichten (letzte 30 Tage)
Christopher
Christopher am 12 Dez. 2013
Kommentiert: Matt Kindig am 12 Dez. 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 Kommentar
Matt Kindig
Matt Kindig am 12 Dez. 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.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by