Question: This is my code from HW 2. Should be formated to run in MatLab. Problem Statement This assignment is based on your HW2. In HW2,

 This is my code from HW 2. Should be formated torun in MatLab. Problem Statement This assignment is based on your HW2.

This is my code from HW 2. Should be formated to run in MatLab.

In HW2, you are given a binary number of length at most

Problem Statement This assignment is based on your HW2. In HW2, you are given a binary number of length at most 6 and you need to convert it to the decimal representation. In this assignment, you need to improve your program so that it can handle input of arbitrary length. This can be done using a for loop and the number of iterations is determined by the input length. Still, you can NOT use existing matlab function to do the conversion. The functions allowed for this assignment are: input(), str2num(), str2double(), length(), disp( and fprintf(). If you want to you functions not listed here, ask me for permission Input Output Hint A binary number of arbitrary length The number in decimal You can use the function length() to get the input length You do NOT need to add leading O's since you will can not fix the length Review your in-class examples to see if you can find the connection to this problem Sample Outputs & Test Cases Test1 Enter the binary number: 101010 The number in decimal is 42. Test2 Enter the binary number: 111000111 The number in decimal is 455 Test3 Enter the binary number: 110111011110 The number in decimal is 3550 Program Complexity My solution code for this program is 11 lines

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!