MATLAB: New variables / variable name in loop -


this extremely remedial question, apologize in advance, i'm pretty new matlab , keep getting stumped @ simple problem.

so, have arbitrary matrix (d) denotes 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 want count out-degree of each node. can calculated using command:

o = cumsum(d,2); o1 = (1,n); ... n in d... 

i trying write loop command script counts out-degree of each node in network , when doing creates new variable. wrote following loop command:

o = cumsum(d,2); i=1:n     o_i = o(i,n) end 

however, keep updating same variable 'o_i' opposed creating new variables, 'o_1,...,o_7' :( .

is there way create new variable each loop??

many thanks,

owen

what want array, thankfully, matlab quite that, can use o(i), it's better initialize first: o=zeros(size(d,2),1).

that been said, in case need sum function: o=sum(d,2), here o(i) out-degree of node i


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

c++ - Clear the memory after returning a vector in a function -

erlang - Saving a digraph to mnesia is hindered because of its side-effects -