您好我不断收到以下代码的错误:
p1是一组细胞 pLeft,pRight,pUp,pDown只是p1在一个方向上旋转
for m =randperm(N^2);
format long
guess= rand;
zz=[4,5,6,7];
zzz={pLeft{m},pRight{m},pUp{m},pDown{m}};
swapmap=containers.Map(zz,zzz);
zzzz={mod(m-N,N^2),mod(m+N,N^2),mod(m-1,N^2),mod(m+1,N^2)};
swapmap2=containers.Map(zz,zzzz);
direction=randperm(4)+3;
if p1{m}(direction(1))>guess
[p1{m}, swapmap(direction(1))] = deal(swapmap(direction(1)),p1{m});
p1{swapmap2(direction(1))}=swapmap(direction(1));
end
if p1{m}(direction(2))>guess
[p1{m},swapmap(direction(2))] = deal(swapmap(direction(2)),p1{m});
p1{swapmap2(direction(2))}=swapmap(direction(2));
end
if p1{m}(direction(3))>guess
[p1{m}, swapmap(direction(3))] = deal(swapmap(direction(3)),p1{m});
p1{swapmap2(direction(3))}=swapmap(direction(3));
end
if p1{m}(direction(4))>guess
[p1{m},swapmap(direction(4))] = deal(swapmap(direction(4)),p1{m});
p1{swapmap2(direction(4))}=swapmap(direction(4));
end
端
我收到以下错误
Cell contents indices must be greater than 0
Error in test3 (line 114)
p1{swapmap2(direction(2))}=swapmap(direction(2));