大智若愚 发表于 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=;

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
页: [1]
查看完整版本: 求大神帮忙,我编的这程序哪里出错了?