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)
Mostra commenti meno recenti
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');
2 Commenti
DGM
il 27 Ago 2024
See also:
Mainly, you need to actually store your output in a variable in order to use it for anything programmatically.
Risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!