数学建模社区-数学中国

标题: 求大神帮忙,我编的这程序哪里出错了? [打印本页]

作者: 大智若愚    时间: 2013-1-22 21:00
标题: 求大神帮忙,我编的这程序哪里出错了?
主程序:
a=4;b=6;c=8;
X=2;Y=4;Z=4;
ua=unifrnd(0,X);ub=unifrnd(0,Y);uc=unifrnd(0,Z);
u=[ua,a-X-ua,ub,b-X-ub,uc,c-X-uc];

af(3)     %求x=3时的af函数的值,

M文件:
function f=af(x)
if x<=2
    f=a
else if x=3
        f=a-c
    else if x>=5
              f=a
              else f=a-u(2)
        end
    end
end

Error: File: af.m Line: 4 Column: 10
The expression to the left of the equals sign is not a valid target for an assignment.


怎么错了呀???????!!!!郁闷死了!!!
谢谢大神啦





作者: hzs2012    时间: 2013-1-23 08:46
else if x=3
应为 else if x==3




欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) Powered by Discuz! X2.5