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=bin2oct(input)
function output=bin2oct(input)

% This function converts a single-digit binary number into corresponding octagonal number.
%  Class of both variables - output and input are "char".
mat_1=['000';
    '001';
    '010';
    '011';
    '100';
    '101';
    '110';
    '111'];
mat_2='01234567';

for i=1:8
    if(input==mat_1(i,:))
        output=mat_2(i);
    end
end

Contact us