Answered You can hire a professional tutor to get the answer.
[Matlab] write 2 functions a. The first checks whether a rook threatens another specific position, on a chessboard.
[Matlab]
write 2 functions
a. The first checks whether a rook threatens another specific position, on a chessboard. The function, TestRookThreat(), accepts one input,chessboard (8 x 8 matrix), which is all zeros except for the position of a rook on it, which is designated by 1, and the position to be tested, which is designated by 2. (1 point)
b. The second is TestKingThreat(), which accepts an input similar to TestRookThreat(), but there the position designated by 1 is occupied by a king rather than a rook. (1 point)
To solve this in a simple manner, you might be aided by the find() function.The function returns the non-‐‐zero indices of a matrix.
i=find([1 0 0; 0 -‐‐3 1]) would thus return i=[1;4;6], for linear indexing.[i,j]=find([1 0 0; 0 -‐‐3 1]) would, however, return i=[1 2 2], j=[1 2 3], for multiple indexing, because the non-‐‐zero indices are (1,1), (2,2) and (2,3).