a=[4 -1 2 -8 4 5 -3 -1 6 -6];i=1;s=0;while i<10if a(i)>0s=s+a(i);endi=i+1;ends
你好同学,你的数组里面正数元素相加即4+2+4+5+6=21,所以并不是你想的16呢,MATLAB计算的是对的有帮助望采纳呢,谢谢啦mua~