# Converting Upper triangle to lower triangle

13 次查看（过去 30 天）
Abe2015-2-1

Hello all, I have a small point that stopping me in some ideas. It is about how to convert the binary lower triangle to xor upper triangular. For example: A = tril(randerr(4,4)); and then get A. I want the upper triangle = xor of A or we can say as conjugate A. The result if we XORed the Upper to Lower we get the zeros or ones.
##### 3 个评论显示 2更早的评论隐藏 2更早的评论
Abe 2015-2-3
The above matrix 4x4 I missed the semicolon.

### 采纳的回答

Youssef Khmou 2015-2-2
If the question consists of converting lower triangular binary matrix into upper triangular one, then is it possible to use logical operation xor, there are two possible values in a={1,0}, the kernel is b=1, so xor(a=1,b)=0 and xor(a=0,b)=1.
n=10;
A=ones(n);
A=tril(A);
B=xor(A,ones(n));
diagonal elements can be adjusted with options of tril function.
##### 1 个评论显示 无隐藏 无
Abe 2015-2-3
Thank you so much brother that is correct.

### 类别

Find more on Math Operations in Help Center and File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!