Answered You can hire a professional tutor to get the answer.

QUESTION

Create a function called matmanip that will receive as input argument a matrix of integers, and will return as output a matrix of equal dimensions,

Create a function called matmanip that will receive as input argument a matrix of integers, and will return as output a matrix of equal dimensions, modified in such a way that the value in each of its elements equals to the sum of the values stored in the corresponding nearest- neighbor elements of the input matrix.

For example, for the input matrix given on the left, the output matrix should have values as shown on the right:

To test your function, create the 5x5 matrix mat = [1 3 0 2 2; 0 5 3 1 4; 3 1 2 0 2; 4 2 1 1 4; 2 0 3 2 5], and then print to screen the output matrix returned by the call matmanip(mat) using MATLAB function disp.

Problem 5. Create a function randpi that will continuously generate random digits until producing a sequence which reproduces π up to n significant figures, where n is the input argument to the function. The function should print the total number of random digits that were generated in the process.

For example, if the call to the function is

>>randpi(3)

digits are to be randomly generated until the sequence 3 1 4 is produced, which corresponds to π with 3 significant figures, i.e., 3.14.

For sake of illustration, shown is a stream of randomly generated digits terminating at 3 1 4:

62942241613494624558375764618056730468499330976020373824054965418834695314

In this particular case, 74 digits were generated prior to reaching the desired sequence. The number 74 would then be output on the terminal. 

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question