Write a MATLAB program to translate the Morse code of text messages back into pl
ID: 660633 • Letter: W
Question
Write a MATLAB program to translate the Morse code of text messages back into plain texts.
Code:
input_str= input ('Enter MorseCode:')
input_str= strrep(input_str, '',',')
input_str= strcat(',', input_str, '',',')
morese_code={'.-','-...','-.-.','-..','.','..-.','--.','....','..','.---','-.-','.-..','--','-.','---','.--.','--.-','.-.','...','-','..-','...-','.--','-..-','-.--','--..','/'};
plain_code= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
for i=1:size(morse_code,2)
str_val= strcat(',', morse_code(i),',');
char = strcar(',', plain_code (i), ',');
i
stri=regexprep(inpute_str,str_val,char);
end
input_str=strrep(input_str, ',','')
This what i have but it shows me error saying "Error (line 1) inpute_str=input ('Enter MorseCode:') PLEASE HELP!!!
PLEASE try running it for yourself.
Explanation / Answer
stri='.---- -. ..--- .. .--- .-.. --... ....- .- .' stri = strcat(' ', stri); morse = {'.-' '-...' '-.-.' '-..' '.' '..-.' '--.' '....' '..' '.---' '-.-' '.-..' '--' '-.' '---' '.--.' '--.-' '.-.' '...' '-' '..-' '...-' '.--' '-..-' '-.--' '--..' '-----' '.----' '..---' '...--' '....-' '.....' '-....' '--...' '---..' '----.'}; code='ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; for i=1:size(morse,2) str = strcat(' ',morse(i)); stri = regexprep(stri,str,code(i)) end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.