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
% matlab code to convert decimal input to binary and octal
number = input(\"Enter a decimal number: \");
bin_str = dec2bin(number);
oct_str = dec2base(bin2dec(bin_str), 8);
disp(\"Binary: \");
disp(bin_str);
disp(\"Octal: \");
disp(oct_str);
%{
output:
Enter a decimal number: 101
Binary: 1100101
Octal: 145
%}
