home

Scientific Computing (Psychology 9040a)

Fall, 2021

Hexadecimal message: sample Solution


Copy and paste the following code into MATLAB, to decode the hexadecimal message into ASCII characters.

Think about what we do to make this code more efficient, more reusable, and less prone to typos and other kinds of mistakes. Specifically, start to think about how we might use different data types and programming constructs to solve this problem using better code.

disp(char(hex2dec('4C')))
disp(char(hex2dec('65')))
disp(char(hex2dec('74')))
disp(char(hex2dec('20')))
disp(char(hex2dec('74')))
disp(char(hex2dec('68')))
disp(char(hex2dec('65')))
disp(char(hex2dec('20')))
disp(char(hex2dec('68')))
disp(char(hex2dec('61')))
disp(char(hex2dec('63')))
disp(char(hex2dec('6B')))
disp(char(hex2dec('69')))
disp(char(hex2dec('6E')))
disp(char(hex2dec('67')))
disp(char(hex2dec('20')))
disp(char(hex2dec('62')))
disp(char(hex2dec('65')))
disp(char(hex2dec('67')))
disp(char(hex2dec('69')))
disp(char(hex2dec('6E')))
disp(char(hex2dec('21')))