How can i convert to the undirected matrix to an directed matrix?

1k Views Asked by At

enter image description here

Here A square matrix and first figure(AU) shows undirected connection graph and second one shows directed one.Assume that only i have Au metrix and how can i create Ad metrix from Au matrix in matlab?

1

There are 1 best solutions below

2
On

If you have the possibility to change the direction of your vectors, take the upper triangular minus the lower triangular:

AD=triu(AU)-tril(AU)

And if you do not want the -1 elements, add

AD(AD==-1)=0

This will direct all your vectors from the smaller to the greater number: 1->2, 2->3, etc ...