Code covered by the BSD License  

Highlights from
NUMBER SYSTEMS/ BASE CONVERTER

image thumbnail

NUMBER SYSTEMS/ BASE CONVERTER

by

 

13 Aug 2006 (Updated )

Convert a number between different number systems-hex,oct,bin,dec.

output=dec2bin2(input)
function output=dec2bin2(input)

% This function converts an array in binary format to an array in decimal format.
%     Class of both variables - output and input are "double".
empt=[];
for i=1:length(input)
    empt=[empt 0]; %#ok<AGROW>
end
d=[];
j=1;
while(j<=9)
    [b c]=div2(input);
    d=[d c]; %#ok<AGROW>
    input=b;
    if(b==empt)
        break;
    end
end
output=fliplr(d);

Contact us