I am attempting to decode morse and the input "decode(—–)" gives me "Error: Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.". Can someone tell me why?
clear all; close all; code = ... [".----";"..---";"...--";"....-";".....";"-....";"--...";"---..";"----.";... "-----";".-";"-...";"-.-.";"-..";".";"..-.";"--.";"....";"..";".---";... "-.-";".-..";"--";"-.";"---";".--.";"--.-";".-.";"...";"-";... "..-";"...-";".--";"-..-";"-.--";"--..";"..--.-"];letter = ... ["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";"-"];%userInput = input("Enter your morse code ");
function message = decode(morseCode)numcharacters = count(morseCode, "/")for i = 1:length(numcharacters) if ismember (morseCode(i), letter) disp(letter(i)) end endend
Best Answer