MATLAB: Short code to calculate and display value of matrix based on condition

MATLABmatrixmatrix manipulation

Hi. I want to calculate new value in matrix C and based on conditions from value of matrix P. I want to display values cell string D in new cell string E based on chosen values of matrix P.
P =
1.0000 0.8181 0.9960 0.0000
0.8181 1.0000 0.5233 0.0000
0.9960 0.5233 1.0000 0.0000
0.0000 0.0000 0.0000 1.0000
D =
'A'
'B'
'C'
'D'
I want to calculate C and display E like this,
-1- if any value of P is less than 0.05, it will become 1, else it will become 0 in C.
-2- Then, sum values of C by each row. For example, row 1, 2, 3 will become 1, row 4 will become 3. After that, I would like to divide total of each row by number of all C columns, which is 4.
C =
0.25
0.25
0.25
0.75
-4- Display E cell string with value from D cell string by matching same column number of P values which is less than 0.05 with row number of D values. It will become like this.
E =
'D'
'D'
'D'
'A','B','C'

Best Answer

First part can be achieved by this:
P = [ 1.0000 0.8181 0.9960 0.0000
0.8181 1.0000 0.5233 0.0000
0.9960 0.5233 1.0000 0.0000
0.0000 0.0000 0.0000 1.0000];
A = zeros(size(P)) ;
A(P<0.05) = 1 ;
second part is not clear.