[求助]if else 的错误
帮忙看看为什么出错 好像是IF ELSE
x=linspace(0,2*pi);
gain=[5,10,20,30,50,80,100];
for i=1:7
y=gain(i)*(sin(x)./(x.*x+1));
c = 2.6 + rand * 0.1 ;
if c <= 1
r = rand * c ;
g = rand * (c - r) ;
b = c - r - g ;
elseif (c > 1) & (c <= 2)
r = rand ;
if r < (c - 1)
g = (c - 1 - r) + rand * (2 - c + r) ;
else
g = rand * (c - r) ;
end
b = c - r - g ;
elseif (c > 2) & (c <= 3)
r = (c - 2) + rand * (3 - c) ;
g = (c - r - 1) + rand * (2 - c + r) ;
b = c - r - g ;
end
plot(x,y,'color',[r g b]);
hold on
end