Please use MATLAB to solve the following problems. Please be sure to include wel
ID: 3790556 • Letter: P
Question
Please use MATLAB to solve the following problems. Please be sure to include well detailed comments to explain all processes. It should be coded in basic MATLAB operations since I am still new to MATLAB. It should be user friendly. Please read instructions carefully. Be sure to include comments!! Thank you,
Problems In this lab, we will use Matlab to implement a variety of problems. Note for all problems listed, the use of built-in functions or libraries is allowed and should be well commented. 1. Decimal Binary and Octal (30 points) Write a series of functions that convert a decimal number into binary and octal 2. Binary and Octal Decimal (30 points) Write a series of functions that convert a binary or octal number back into decimal. For Problems 1 and 2, check your functions with the following: 10 Decimal 1010 Binary 12 Octal 20 10100 24octal Decimal Binary 3. Binary Addition (40 points) Write a function that adds two binary numbers that are entered by the user. You may represent each binary number as a string of 0's and 1's Remember that the calculations need to start at the end of the strings. For binary numbers of different length, you may pad the shorter number with 0's in the front. Also, make sure that the carry bit is implemented properly. For example, the solution of 1 t 1 10Explanation / Answer
hello,
Lets consider the decimal number to be 142. In matlab we have a function called dec2base which converts decimal to base B string.
dec2base(D,B) where D is decimal number and B is base
decimal_number=142;
oct_number=dec2base(decimal_number,8);
binary_number=dec2base(decimal_number,2);
Now for converting binary to decimal,there is function called bin2dec(B) where B is binary representation
bin_number='1010';
dec_number=bin2dec(bin_number);
And for octal to decimal,lets use base2dec('string',base)
oct_number='100';
dec_number=base2dec(oct_number,8);
Binary addition:
A=input('Enter 1st number');
B=input('Enter 2nd number');
fliplr(de2bi(bi2de(fliplr(A))+bi2de(fliplr(B))));