Question: Write a Matlab function that converts a non negative integer written in decimal base to its equivalent form expressed on an arbitrary base b 10.

Write a Matlab function that converts a non negative integer written in decimal base to its equivalent form expressed on an arbitrary base b ≤10. Store the output in a vector. On input, the function must accept the number n, the base b, and the maximum number of digits m. On output, the function must return a vector of length m. If the number causes an overflow (i.e., it is bigger than what can be represented with m digits on that base), the vector must be filled with NaNs. The program must check that b > 1. If b ≤1 it must return a vector of -1’s. The return expression must contain the Most Significant Digit in the first entry of the vector. For example, if the number is 99 = 1 ×81 + 2 ×9, the base is 3 and m = 7, then the answer is [0 0 1 0 2 0 0]. For the same number, but the base is 5 and m = 4 then the answer is [0 3 4 4].

Question 2. Given a positive integer expressed in an arbitrary base b > 1, write a function to express it as a decimal. On input the function takes a vector v (of arbitrary length) that contains the digits, and the base b. Returns n.

Question 3. It is well known that π 4= arctan(1). Use the Taylor series for the arctan function at the origin to write π 4as a series. Write a function that returns the error when π 4is evaluated truncating the series after n terms. For the exact value of π use the builtin MATLAB variable pi.

Step by Step Solution

3.33 Rating (150 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Sure lets start with the first question Heres a MATLAB function ... View full answer

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 Programming Questions!