Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a function that computes the M matrix for a given set of games. Note that

ID: 3908452 • Letter: W

Question

Write a function that computes the M matrix for a given set of games. Note that the paper refers to this matrix as the incidence matrix, but the more typical term for this mat ix is the adjacency matrox Your Function C Reset BB MATLAB function M - adj matrix(G,n_teams) % computes the adjacency matrix M for a set of games % initialize with self-loops M = eye(n-teams); 3 loop over the rows of G for r-1:size(G,1) % get the teams 3 G(r,2); % update adjacency matrix 10 '% YOUR CODE HERE end end Code to call your function n teams 4 2 G I 1, 2, 5, 10; 1, 4, 57, 45; 2, 3, 10, 7; 2, 4, 3, 1e : adj matrix(G,n teans)

Explanation / Answer

function M=adj_matrix(G,n_teams)

M=eye(n_teams)
for r=1:size(G,1)
i=G{r,1};
j=G{r,2};
%my code
c=G{r,3};
d=G{r,4};
M(i,i)=M(i,i)+c-d
M(j,j)=M(j,j)+d-c
end


end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote