Pls I need hel with Matlab 3. Create a 10 by 10 matrix A of 0 and 1s generated r
ID: 1995842 • Letter: P
Question
Pls I need hel with Matlab
3. Create a 10 by 10 matrix A of 0 and 1s generated randomly. Create a second matrix whose matrix, B, with the same size 10 by 10. Individual elements of B are referenced using B[i,j], where i is the row and j is the column. Define each element within B as B[i,j] = sin(i) cos(j) where both i and j go from 1 to 10 [Hint: B[1,1]=sin(1)*cos(1)].
Do all of the following:
a.Compute the determinants of A and B
b. The mean of each row of A and B should be computed. The resulting sequence of numbers (means of each row) from A should be stored in a variable rmA, which will be a column vector. Similarly, the sequence of numbers from B should be stored in a variable rmB which will also be a column vector. A column vector is a sequence of numbers stored as a vertical array with a width of 1.
c. Compute the matrix product of A X B. Using this resulting matrix, once again calculate the mean of each row, and assign the sequence of values to the column vector rmAB.
d. Compute the maximum values for each of these variables, rmA, rmB and rmAB. Report which row each maximum value came from. For example, “The maximum value of rmA was 3, which came from row 7 of the original matrix”
Explanation / Answer
A = rand(10,10);
B = zeros(10,10);
for i=1:10
for j=1:10
B(i,j)=sin(i)*cos(j);%populating B matrix
end
end
detA = det(A);
detB = det(B);
rmA = mean(A,2);%gives mean of each row
rmB = mean(B,2);
AB = A*B;
rmAB = mean(AB,2);
maxrmA = max(rmA);
maxrmB = max(rmB);
maxrmAB = max(rmAB);%finds max value of column vector
indexmaxrmA = find(rmA==max(rmA));
indexmaxrmB = find(rmB==max(rmB));%determines index of max value
indexmaxrmAB = find(rmAB==max(rmAB));