Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Matlab Common functions and indexing. Make eSum the column-wise sum of cMat. The

ID: 3839357 • Letter: M

Question

Matlab Common functions and indexing. Make eSum the column-wise sum of cMat. The answer should be a row vector (use sum). Make eMean the mean across the rows of eMat. The answer should be a column (use mean) Replace the top row of eMat with [1 1 1] Make esub the submatrix of eMat that only contains rows 2 through 9 and columns 2 through 9. Make the vector lin = [1 2 .... 20] (the integers from 1 to 20, and then make every other value in it negative to get lin = [1 -2 3 -4 ... -20]. Make r a 1 times 5 vector using rand. Find the elements that have values

Explanation / Answer

% Question 7: Common Functions and Indexing. % 7.a cSum = sum(cMat) % 7.b eMean = mean(eMat).' % 7.c eMat(1, :) = [1 1 1] % 7.d cSub = cMat(linspace(2, 9, 8), linspace(2, 9, 8)) % 7.e lin = reshape(linspace(1, 20, 20), 2, 10); lin(2, :) = lin(2, :)*-1; lin = reshape(lin, 1, 20) % 7.f r = rand(1, 5); r(find(r < 0.5)) = 0