So I had to create a MATLAB Morse Code encoder program. So I got all that done (proud of myself), but then the professor asked to make a decoder. I have my encoder script done. Is there anyway to modify it to make it decode ? Or do I need a new scrip

11 visualizzazioni (ultimi 30 giorni)
word = input ('Insert Text You Desire To Convert Now \n','s');
word = upper(word);
word = strjoin(strsplit(word));
morse={'.----','..---','...--','....-','.....','-....','--...','---..','----.','-----','.-','-...','-.-.','-..','.','..-.','--.','....','..','.---','-.-','.-..','--','-.','---','.--.','--.-','.-.','...','-','..-','...-','.--','-..-','-.--','--..','/'};
NumberOrLetter={'1','2','3','4','5','6','7','8','9','0','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',' '};
for i=1:length(word);
[~, index] = ismember(word(i), NumberOrLetter);
if index > 0
fprintf('%s',morse{index});
end
end
fprintf('\n');

Risposte (0)

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by