Calculating how many runs die out
1 view (last 30 days)
Show older comments
I want to calculate how many runs die out out of k amount of runs. This doesn't work. How can i make it so the amount of runs dying out a vector where its 1 when it dies out or 0 when it doesnt?
A=createsrandomnetwork(10,1);
I=zeros(10,1);
positions=[1,1];
I(positions)=1;
v=zeros(1,10); %Vector which proportion value will be saved into
n=numel(I); %n=number of array elements
for k=1:10
dieout=zeros(10,k);
for i=1:10
a = rand(10);
R = triu(a) + triu(a,1)';
H=R>0.1; %Matrix with % chance of passing on infection
P=A.*H; %New Network Matrix including the probability
P(logical(eye(size(P)))) = 0; %makes sure the diagonal is 0 then people can recover
I=P*I; %New Network Matrix times the Vector of Infected
v(i)=nnz(I)/n %Proportion infected at time i
if sum(I)==0
dieout(k)=1
break
end
end
end
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!