This is probably an extremely remedial question, so I apologize in advance, however I'm pretty new to MATLAB and keep getting stumped at this simple problem.
So, I have an arbitrary matrix (D) that denotes a directed network:
D = [0,1,1,0,0,0,0;
0,0,0,1,1,0,0;
0,0,0,0,1,0,0;
0,0,0,0,0,1,0;
0,0,0,0,0,1,0;
0,0,0,0,0,0,1;
0,0,0,0,0,0,0]
n = length(D);
All that I want to do is count the out-degree of each node. This can be calculated easily using the command:
O = cumsum(D,2);
O1 = (1,n);
... for all n in D...
I am just trying to write a loop command so that the script counts the out-degree of each node in the network and when doing so creates a new variable. I wrote the following loop command:
O = cumsum(D,2);
for i=1:n
O_i = O(i,n)
end
However, I keep just updating the same variable 'O_i' as opposed to creating new variables, 'O_1,...,O_7' :( .
Is there any way to create a new variable for each loop??
Many thanks,
Owen