Welcome to SO! Please read the following guide on how to ask good questions.
To elaborate on @Ankur's comment, please also take a look at this Open letter to students with homework problems: "...If your question is just a copy paste of homework problem, expect it to be downvoted, closed, and deleted - potentially in quite short order."
What you need to do is pretty straight-forward:
- First you preallocate your
M matrix, using either M=zeros(6); or M(6,6)=0; (this option assumes M does not exist).
- Next thing you should note is that MATLAB uses "1-based indexing", which means that you can't use the indices in
A as-is and you first need to increment them by 1.
- After incrementing the indices, we see that
"A+1" contains the coordinates of M that should have a 1 in them (I noticed that the adjacency matrix is asymmetric in your case). From here it's a matter of accessing the correct cells, and this can be done using sub2ind(...).
Finally, the code to generate M is:
M=zeros(6);
M(sub2ind(size(M), A(:,1)+1, A(:,2)+1))=1;