⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 adjcentmatrix - 复制.m

📁 该matlab程序可得到规则随机方形网络的邻接矩阵
💻 M
字号:
clear;
p=0.5;       %the probability of the bonds
N=50;        %the number of nodes is N^2
%%%%%%%%%%%%%create the adjacency matrix of a percolation network
B=zeros(N^2);
for i=1:2:(2*N-1)
    for j=2:N
        if rand(1)+p>=1
            B((i-1)*N/2+j-1,(i-1)*N/2+j)=1;            
            B((i-1)*N/2+j,(i-1)*N/2+j-1)=1;
        end
    end
end
for i=2:2:(2*N-2)
    for j=1:N
        if rand(1)+p>=1
            B((i/2-1)*N+j,(i/2)*N+j)=1;            
            B((i/2)*N+j,(i/2-1)*N+j)=1;
        end
    end
end
%%%%%%%%%%%%%%end the creatation
P=length(find(B==1))/N^4
B=sparse(B); %transfer to sparse matrix to save memory

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -