matlab循坏程序,matlab循环程序求助

CODE:

while 1

outnneighbors = zeros(1,n);

innneighbors = zeros(1,n);

G = directG(n,dist,thresh);

Graph.P = pos;

outcount = 0;

incount = 0;

for i=1:n

outneighbors{i} = find(G.A(i,:));%find function - return the all nonzero elements of array (G(i,:)),row

%  即,返回数列的非零值坐在的列数,G中有几个非零数即表示有几个邻居节点,因为G为

%  图的邻接矩阵,如果相邻节点之间存在edge,则取值为1

outnneighbors(i) = numel(outneighbors{i});%numel function-return the number of elements,n, in array(neighbors{i})

outcount = outcount +1;

if outnneighbors (i) ==0

break;

else

inneighbors{i} = find(G.A(:,i));%find function - return the all nonzero elements of array (G(i,:)),row

%  即,返回数列的非零值坐在的列数,G中有几个非零数即表示有几个邻居节点,因为G为

%  图的邻接矩阵,如果相邻节点之间存在edge,则取值为1

innneighbors(i) = numel(inneighbors{i});%numel function-return the number of elements,n, in array(neighbors{i})

incount = incount +1;

if innneighbors (i) ==0

break;

end

if incount >= n

break;

end

end

if outcount >= n

break;

end

break;

end

end

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值