I have one matrix and i drew a bipartite graph Like below in MATLAB .
F =
1 0
2 1
3 0
4 0
5 1
6 0
plot(F','-*','Color','b','LineWidth',1,'MarkerEdgeColor','r')
axis([0, 3, -2, size(F, 1) + 1])
In this case all line are connected (0 and 1) of 2nd column separately. But I want to connect only if the element of 2nd column is equal to 1. No need for 0. How can I draw or how can I write code in MATLAB?
Just change:
plot(F','-*','Color','b','LineWidth',1,'MarkerEdgeColor','r')
... to:
plot(F(F(:,2) == 1,:)','-*','Color','b','LineWidth',1,'MarkerEdgeColor','r')
By changing F
to F(F(:,2) == 1,:)
you're telling Matlab to use only the rows of F
where the second column equals to 1.