matlab中for循环内给数组赋值 5
Pa=[1,2,3,2,1,4,5,7,6,5,4,3];fork=0:1:11a1=Pa(k);a2=Pa(k+1);a3=Pa(k+2);a4=Pa(k+3);a5=...
Pa=[1,2,3,2,1,4,5,7,6,5,4,3];
for k=0:1:11
a1=Pa(k);
a2=Pa(k+1);
a3=Pa(k+2);
a4=Pa(k+3);
a5=Pa(k+4);
if a1<=a2
if a2<=a3
if a3>a4
if a4>a5
a=k+2;
w=a3;
else if a3>a5
a=k+2;
w=a3;
end
end
end
end
end
end
运行的时候,提示
Attempted to access Pa(0); index must be a positive integer or logical.
Error in Untitled2 (line 4)
a1=Pa(k);
求解答!!!谢谢 展开
for k=0:1:11
a1=Pa(k);
a2=Pa(k+1);
a3=Pa(k+2);
a4=Pa(k+3);
a5=Pa(k+4);
if a1<=a2
if a2<=a3
if a3>a4
if a4>a5
a=k+2;
w=a3;
else if a3>a5
a=k+2;
w=a3;
end
end
end
end
end
end
运行的时候,提示
Attempted to access Pa(0); index must be a positive integer or logical.
Error in Untitled2 (line 4)
a1=Pa(k);
求解答!!!谢谢 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询