Getting "Error: This statement is incomplete."
73 次查看(过去 30 天)
显示 更早的评论
Hello. This is my code and I keep getting the error "This statement is incomplete." several times throughout but can't find the mistake.
6
figure (6);
v1 = [1 0 -5 0 0 4];
k=1;
for i=[-3 : 0.2 : 3]
p1 (k) = polyval(v1,i);
k = k+1;
j=1;
for i=[-3 : 0.2 : 3]
if i >= 0
v2 (j) = i^3;
j = j+1;
else if i < 0
v2 (j) = i^3 * (-1);
j = j+1;
end
end
end
plot (p1); grid on; hold on;
plot (v2);
Here's the errors:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/171973/image.jpeg)
4 个评论
回答(2 个)
Walter Roberson
2018-4-9
There is no end for the first for loop. You start a second for i without an end for the first.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!