Cell contents assignment to a non-cell array object

我们两清 提交于 2019-12-12 02:05:01

问题


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?


回答1:


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).



来源:https://stackoverflow.com/questions/15265311/cell-contents-assignment-to-a-non-cell-array-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!