I know that if you have a matrix A, triu(A) will fill the lower triangular matrix with zeros, but is there a way to make that ones instead of zeros? Thanks!
Best Answer
No. You cannot tell triu to fill with ones instead of zeros. That does not mean what you are asking is impossible, just that you need to be creative in how you use these tools.
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.
Best Answer