Numerical Analysis Matlab Write a Matlab program to convert

Numerical Analysis

Matlab

Write a Matlab program to convert any decimal number between decimal, octal and binary systems. Your program will prompt the user to input a number, the system it is and the system it will convert to

Solution

num=input(\'enter a number : \');

inbase=input(\'enter input base :\');

outbase=input(\' enter output base : \');

if(inbase==10)

fprintf(num,\' in base \',outbase,\'=\',dec2base(num,outbase));

end

if(inbase==2)

if(outbase==10)

disp(bin2dec(num));

end

if(outbase==8)

disp(dec2base(bin2dec(num),8));

end

end

if(inbase==8)

if(outbase==10)

disp(oct2dec(num));

end

if(outbase==2)

disp(dec2bin(oct2dec(num))

end

end

Numerical Analysis Matlab Write a Matlab program to convert any decimal number between decimal, octal and binary systems. Your program will prompt the user to i

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site