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 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
DGM
2024 年 8 月 27 日
See also:
Mainly, you need to actually store your output in a variable in order to use it for anything programmatically.
回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!