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 views (last 30 days)
Show older comments
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 Comments
DGM
on 27 Aug 2024
See also:
Mainly, you need to actually store your output in a variable in order to use it for anything programmatically.
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!