Create a MATLAB script called a2task2.m that computes the following: 1. Create a
ID: 3747417 • Letter: C
Question
Create a MATLAB script called a2task2.m that computes the following: 1. Create a matrix using the following line of code: A-gallery ('moler',10). Use array subscripting to assign the 3 column of A to a new vector named vec. 2. Assign the maximum value in vec to a new variable named v_max and the minimum value in vec to a new variable named v_min. Use the repmat command to create a new 2x10 matrix called M such that each row of M is the transpose of vec. 3. 4. Assign the diagonal elements of matrix A to a 10-element column vector named diagM. (Hint: 5. Create a row vector samplesl that contains exactly 99 equally-spaced points ranging from 0 6. Create a row vector samples2 that contains points spaced exactly 0.1 units apart over the there is a MATLAB command that will help you with this) to 100. range of 0 to 2.25Explanation / Answer
Question 1
Answer -
Question 2
Answer -
Now lets calculate maximum and minimum value from the vector
v_max = max(vec) ;
v_min = min(vec) ;
Qustion 3
Answer -
Now lets create a 2*10 matrix with every row in M is transpose of vec
M = repmat(transpose(A),2,10) ;
Qustion 4
Answer -
Lets create vector digM that contains diagonal elments of matrix A.
digM = diag(A)
Qustion 5
Answer -
Lets creat matrix sample1