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

slove this question by using the MATLAB. Overview Complete the implementation of

ID: 3710934 • Letter: S

Question

slove this question by using the MATLAB.

Overview Complete the implementation of the selectColumns function, which selects the contents of several columns from a matrix, A. The matrix will be supplied to the function as an input variable. The function should return a matrix B, which contains every fifth column of A. The first column of your result should be column 5 of A. Input variable: A- A matrix, the number of columns of which are guaranteed to be an even multiple of 5. This means you do not need to take any special precautions about the dimensions of A. Keep your solution simple. Output variables: B- A matrix containing every fifth column of A. Function Template function B = selectColumns( A ) B = []; end Hints: 1. Matrix indexing will be useful in solving this exercise. Information can be found in sections 9.3 and 9.4 of the Introduction to Programming in MATLAB document on Blackboard.

Explanation / Answer

function B = selectColumns(A)
    B = [];
    [r, c] = size(A);
    i = 1;
    for j=5:5:c
        B(:, i) = A(:, j);
        i=i+1;
    end
end