count=[4,1,3,6,1,2,5,7,1,2];
>> NIND=10;
for i=1:NIND
if count(i)==0 R2(i)=0;
else if 0<count(i)<=2 R2(i)=10000000;
else if 2<count(i)<=6 R2(i)=20000000;
else if 6<count(i)<=10 R2(i)=30000000;
else R2(i)=60000000;
end
end
end
end
end
运行结果总是是R2 =
Columns 1 through 8
10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000
Columns 9 through 10
10000000 10000000
我改变count的值,可结果还是一样的,哪位高手能告诉我问题出在哪里呀,先谢谢啦!
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
NIND=10;
for i=1:NIND
if count(i)==0 R2(i)=0;
else if (0<count(i))&(count(i)<=2) R2(i)=10000000;
else if (2<count(i))&(count(i)<=6) R2(i)=20000000;
else if (6<count(i))&(count(i)<=10) R2(i)=30000000;
else R2(i)=60000000;
end
end
end
end
end
>> R2
R2 =
20000000 10000000 20000000 20000000 10000000 10000000 20000000 30000000 10000000 10000000
你的程序之所以错误,是因为逻辑运算出现错误了,按你的0<count(i)<=2,表示的是或运算,也就是有一边为真,那么判读为1,就执行运算了。
一周热门 更多>