from
NUMBER SYSTEMS/ BASE CONVERTER
by Divakar Roy
Convert a number between different number systems-hex,oct,bin,dec.
|
| output=hex2bin(input)
|
function output=hex2bin(input)
% This function converts a single-digit hexagonal number into corresponding binary number.
% Class of both variables - output and input are "char".
mat_1=['0000';
'0001';
'0010';
'0011';
'0100';
'0101';
'0110';
'0111';
'1000';
'1001';
'1010';
'1011';
'1100';
'1101';
'1110';
'1111';];
mat_2='0123456789ABCDEF';
for(i=1:16)
if(input==mat_2(i))
output=mat_1(i,:);
end
end
|
|
Contact us at files@mathworks.com