資源簡介
matlab實現隨機網絡、小世界網絡、無標度網絡的傳染病模型
代碼片段和文件信息
tic
clear
clc
n=1000;?%vertex?of?the?network
p=0.01;?%the?probability?of?link
%%%%%%%%%%%%%%%%%?生成一個N個節點連接概率p的隨機圖網絡.
A=sparse(nn);
for?i=1:n-1
????for?j=i+1:n
??????
????????if?rand???????????A(ij)=1
??????A(ji)=A(ij);
????????end
????end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for?y=1:100
??S=zeros(1n);?
??R=unidrnd(n11);????????????%%%%%%%%%%%%%選一個初始感染者
??S(R)=1;
?for?t=1:150%%%%%%%%%%%%%%%傳染病毒
??????for?i=1:n
??????????if(S(i)==1)?%%%傳染者以P幾率傳播病毒,易染者變為病毒傳播者
????????????for?j=1:n
????????????????if(A(ij)~=0&S(j)==0)
????????????????????r1=rand(1);
????????????????????if(r1<0.02)??
????????????????????????S(j)=1;
????????????????????end
????????????????end???
????????????end????????
??????????end????????
??????end
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????3888??2011-04-09?21:21??ERSWBA.m
- 上一篇:lcl濾波器的三相光伏逆變器
- 下一篇:融合算法
評論
共有 條評論