回 帖 发 新 帖 刷新版面

主题:哪位大哥帮帮忙,小弟刚学matlab,代码看不明白

关于锁具装箱的一个问题
count=0;
for h1=1:6
    a(1)= h1;
    for h2=1:6
        a(2)= h2;
        for h3=1:6
            a(3)= h3;
            for h4=1:6
                a(4)= h4;
                for h5=1:6
                    a(5)= h5;
                    [color=008080][color=0000FF][color=FF0000]s=0;flag=1;
                    b=sort(a); c=diff(a);d=diff(b);
                    for i=1:4
                        if d(i)~=0
                            s=s+1;
                        end
                        if abs(c(i))==5
                            flag=0;
                        end
                    end
                    if s>=2&flag
                        count=count+1;[/color][/color][/color]
                    end
                end
            end
        end
    end
end
count

哪为大哥帮我看看,
我保存为count.m文件
运行的时候提示
??? Error: File: d:\MATLAB7\work\count.m Line: 2 Column: 1
The variable "count" is also the name of this script.
 This is illegal, because it will be the name of a script and a variable
 in any context from which the script is called.
中间这段字体颜色不同的代码什么意思啊,小弟刚学习建模,刚接触matlab.望哪位高手帮小第解释一下..........

回复列表 (共2个回复)

沙发

??? Error:有个变量 也叫count

板凳


count 是内部函数名,换个变量

我来回复

您尚未登录,请登录后再回复。点此登录或注册