Question: ( 8 points ) Use a for - loop to define a function to convert a text representing a binary number to decimal integer, and

(8 points) Use a for-loop to define a function to convert a text representing a binary number to
decimal integer, and then test it as described below.
(1) Write a user-defined MATLAB function (named mybin2dec) that takes one single
valued text input argument representation of a binary number and converts it to a
decimal integer. You are not allowed to use MATLAB bin2dec function in your
function definition, but can use it to check whether your function works correctly.
(2) Write a MATLAB script file that calls mybin2dec function and prints to the screen the
values of binary numbers in the range of '0' to '1100100'(i.e.0 to 100 in decimal).
Hint: you can use a for loop and the MATLAB function dec2bin to generate the binary
numbers in the range specified above.
What to submit for this question: Please submit a plain text file (named a4q1.txt) that
contain the contents of both the function file and the script file. Note that, to run the program,
you need to have two separate files. But to submit them, you need to combine them (by copy
and paste) into the a4q1. txt file to save paper when the TA prints them out.
 (8 points) Use a for-loop to define a function to convert

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!