1) Use a 'for loop' to create an (n x n) matrix M where each element is either 1 or 0. No two adjacent elements are the same, and M(1,1) = 1. Use the input variable n and name the function myMatrix. Write the function in the correct format to be used to create a MATLAB function.
2) Create a function to output a one-dimensional double array M with n elements where the first three elements are 1, and each subsequent element is the sum of the previous three elements before it. Name the function myArray. Write the function in the correct format to be used to create a MATLAB function. Call the function in the correct format to output the array with 7 elements.
3) factorial n = n! = n * (n-1) * (n-2) * ... * 3 * 2 * 1 [For our purpose, you may assume n > 0]. nCr (n Combination r) is the number of ways r elements can be chosen from n elements where the order of choice does not matter. [For our purpose, assume r < n]. nCr = n! / (r! * (n-r)!). Write a function myCombination to calculate 'n Combination r' (i.e., nCr) by calling a subfunction myFactorial. Write the subfunction myFactorial to calculate the factorial of a number n, without using any built-in function like factorial(n) or prod(1:n), etc. Use a 'for loop' and elementary mathematical operations like multiplication, addition, subtraction, and division. [The stated elementary operations are just examples. You may not need all of them]. For myFactorial, use the output variable fact and the input variable n. For myCombination, use the output variable nCr and the input variables n and r.
4. Write a MATLAB script to output an animated plot of sin(x) versus x. In the same plot, produce the animated plot of cos(x) versus x. Use x going from -10 to 10 with 100 equidistant points. Sin(x) should be plotted in black right-pointing triangles. Cos(x) should be plotted in green circles. Include a legend for the plots to properly identify.
5. Write a MATLAB script using a 'while loop' to output all the integers n between 1 and 50 such that (n^3 - n^2) > 1000 and n is not divisible by 3. [If you want, you may display those values of n by correctly using the command disp(n) in your MATLAB script].
6. Write a MATLAB function myNewArray in the correct format which takes as input a one-dimensional double array A with an even number of elements. It produces an output array out with half the number of elements as A. Each element of out is the sum of the corresponding element of A from the beginning of A and the corresponding element of A from the end of A. [example: A = [A1, A2, A3, A4, A5, A6], out = [A1+A6, A2+A5, A3+A4] and so on]