MATLAB: How to load a text file and convert it to hexadecimal and vice versa

convertmatlab function

am new to matlab and i need to convert a text file to hexadecimal and i don't know where to start , any help would be welcomed

Best Answer

>> str = '1Hello';
>> hex = dec2hex(double(str))
hex =
31
48
65
6C
6C
6F
>> char(hex2dec(hex)).'
ans = 1Hello
You can load the file using fileread:
str = fileread(...);