Given matrix A = [0, 2, 1; 3, 1, 0; 4, 6, 4; 2, 0, 2], create a matrix with 1’s at locations where a has zeros and 0’s elsewhere. Create a matrix containing all 0’s except the maximum elements in each row of ‘A’.

 

Given matrix A = [0, 2, 1; 3, 1, 0; 4, 6, 4; 2, 0, 2], create a matrix with 1’s at locations where a has zeros and 0’s elsewhere. Create a matrix containing all 0’s except the maximum elements in each row of ‘A’.

Solution:

A=[0,2,1;3,1,0;4,6,4;2,0,2] B=[A==0] [C,D]=max(A,[],2) A(A~=C(1) & A~=C(2) & A~=C(3) & A~=C(4))=0









Comments