I have this matrix:
A=[2 0 1; 1 2 1; 2 2 1]; %main matrix
I want a code that can extract two matrices, one with 1's elements and anything else is zero and the second matrix with 2's elements and anything else is zero. So, I want to get them as following:
a1=[0 0 1; 1 0 1; 0 0 1] % sub matrix with 1's elements only
a2=[2 0 0; 0 2 0; 2 2 0] % sub matrix with 2's elements only
Can anyone helps?
Best Answer