当前位置: 动力学知识库 > 问答 > 编程问答 >

matlab - Cell contents assignment to a non-cell array object

问题描述:

for ch=1:63

for h=1:5

for a=1:6

for b=1:6

m{a,b}{h,ch}=zeros(4,4);

end

end

end

end

for a=1:6

for b=1:6

if b==a

for h=1:5

for ch=1:63

for c=1:4

for d=1:4

m{a,b}{h,ch}{c,d}=1;

end

end

end

end

end

end

end

The error was appeared in line 17 ( m{a,b}{h,ch}{c,d}=1; ),it showed that the cell contents assignment to a non-cell array object. Any solution to solve this type of error?

网友答案:

This is a horrible code.

As for the error, the variable referenced to by m{a,b}{h,ch} was assigned in line 5 to a 4x4 array not a cellarray. Therefore, you should change line 17 to

m{a,b}{h,ch}(c,d)=1;

Note the difference between regular parentheses (when accessing arrays) and curly braces (when accessing cellarrays).

分享给朋友:
您可能感兴趣的文章:
随机阅读: