Question: Can you help me make these programs and if possible please post the picture of how you input it in the MATLAB editor 1. Write


Can you help me make these programs and if possible please post the picture of how you input it in the MATLAB editor
1. Write a function called circle that takes a scalar input r. It needs to return an output called area that is the area of a circle with radius r and a second output, cf that is the circumference of the same circle. You are allowed to use the built-in function pi. In fact, you need to use it to get the value of n as accurately as possible. 2. The function move_me is defined like this: function w = move_me(v,a). The first input argument v is a row-vector, while a is a scalar. The function moves every element of v that is equal to a to the end of the vector. For example, the command >> X = move_me([1 2 3 4],2); makes x equal to (1 3 4 2]. If a is omitted, the function moves occurrences of zeros. 3. Write a function called even_index that takes a matrix, M, as input argument and returns a matrix that contains only those elements of M that are in even rows and columns. In other words, it would return the elements of Mat indices (2,2), (2,4), (2,6), -, (4,2), (4,4), (4,6), -, etc. Note that both the row and the column of an element must be even to be included in the output. The following would not be returned: (1,1), (2,1), (1,2) because either the row or the column or both are odd. As an example, if Mwere a 5-by-8 matrix, then the output must be 2-by-4 because the function omits rows 1, 3 and 5 of M and it also omits columns 1, 3, 5, and 7 of M. 4. Write a function called flip it that has one input argument, a row vector v, and one output argument, a row vector w that is of the same length as v. The vector w contains all the elements of v, but in the exact opposite order. For example, is v is equal to [1 2 3] then w must be equal to 13 2 1]. You are not allowed to use the built-in function flip, fliplr, or flipud. 5. Write a function called top_right that takes two inputs: a matrix N and a scalar non-negative integer n, in that order, where each dimension of N is greater than or equal to n. The function returns the n-by-n square subarray of N located at the top right corner of N. 6. Write a function called light_speed that takes as input a row vector of distances in kilometers and returns two row vectors of the same length. Each element of the first output argument is the time in minutes that light would take to travel the distance specified by the corresponding element of the input vector. To check your math, it takes a little more than 8 minutes for sunlight to reach Earth which is 150 million kilometers away. The second output contains the input distances converted to miles. Assume that the speed of light is 300,000 km/s and that one mile equals 1.609 km. 7. Write a function called income that takes two row vectors of the same length as input arguments. The first vector, rate contains the number of various products a company manufactures per hour simultaneously. The second vector, price includes the corresponding per item price they sell the given product for. The function must return the overall income the company generates in a week assuming a 6-day work week and two 8-hour long shifts per day. 8. Write a function called intquad that takes as its input arguments two scalar positive integers named n and m in that order. The function returns 0, a 2n-by-2m matrix. Q consists of four n-by-m submatrices. The elements of the submatrix in the top left corner are all as, the elements of the submatrix at the top right are 15, the elements in the bottom left are 25, and the elements in the bottom right are 35. 9. Write a function called sindeg that takes a matrix input called deg. The function returns a matrix of the same size as deg with each of its elements containing the sine of the corresponding element of deg. Note that the elements of deg are given in degrees and not radians. As a second output, the function returns a scalar that contains the average value of the first output. You are not allowed to use the sind and cosd built-in functions, but the use of any other function is acceptable. 10. Write a function called halfsum that takes as input an at most two- dimensional array A and computes the sum of the elements of A that are in the lower right triangular part of A, that is, elements in the counter-diagonal (going from the bottom left corner, up and to the right) and elements that are to the right of it. For example, if the input is (1 2; 3 4; 5 6; 7 8], then the function would return 21
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
