MATLAB: Question about the sign

sign matrix

i have this matrix
H =
1 1 1 1 1 1 1 1
1 -1 1 -1 1 -1 1 -1
1 1 -1 -1 1 1 -1 -1
1 -1 -1 1 1 -1 -1 1
1 1 1 1 -1 -1 -1 -1
1 -1 1 -1 -1 1 -1 1
1 1 -1 -1 -1 -1 1 1
1 -1 -1 1 -1 1 1 -1
i did this code H(se+1,:)=2 H(s0+1,:)=5 to put 2 in some rows and 5 in the rest i get this
H =
2 2 2 2 2 2 2 2
5 5 5 5 5 5 5 5
5 5 5 5 5 5 5 5
2 2 2 2 2 2 2 2
5 5 5 5 5 5 5 5
2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2
5 5 5 5 5 5 5 5
it is correct but the problem that i want to keep the sign of H
i have to get this H =
2 2 2 2 2 2 2 2
5 -5 5 -5 5 -5 5 -5
5 5 -5 -5 5 5 -5 -5
2 -2 -2 2 2 -2 -2 2
5 5 5 5 -5 -5 -5 -5
2 -2 2 -2 -2 2 -2 2
2 2 -2 -2 -2 -2 2 2
5 -5 -5 5 -5 5 5 -5
help me, Thanks :)

Best Answer

Use sign function
In your case you can use
H(se+1,:)=2*H(se+1,:)
Related Question