How to make successive for loops?!
이전 댓글 표시
Hey everybody;
i want to make 3 successive loops that the next loop start from the end of the previous ....can any one help me through that?!
code is attached
채택된 답변
추가 답변 (1개)
Image Analyst
2016년 4월 1일
It's basically like this. Adapt as needed:
for k1 = 1 : 4
k1 % Echo to command window
end
for k2 = (k1+1): (k1 + 5);
k2 % Echo to command window
end
for k3 = (k2+1): (k2 + 2);
k3 % Echo to command window
end
댓글 수: 10
Mariam Sheha
2016년 4월 1일
Torsten
2016년 4월 1일
편집: Image Analyst
2016년 4월 1일
Does this help ?
for k1=1:1000
if y(k1) < 0
break;
end
end
for k2=k1+1:1000
...
end
Best wishes
Torsten.
Mariam Sheha
2016년 4월 1일
Mariam Sheha
2016년 4월 1일
Image Analyst
2016년 4월 1일
편집: Image Analyst
2016년 4월 1일
Undefined function or variable 'R'.
Error in test3 (line 29)
z1(i)= ((50*R.^2)/m) *(sqrt(u1(i).^2 + v1(i).^2));
Torsten
2016년 4월 1일
Something like that ?
for i=1:t1
% position of the ball
% y-axi
y1(i+1)=y1(i)+(h*v1(i));
%x-axis
x1(i+1)=x1(i)+(h*u1(i));
% air resistance
z1(i)= ((50*R.^2)/m) *(sqrt(u1(i).^2 + v1(i).^2));
% velocity in x and y
v1(i+1)=v1(i)-(h*(g+(z1(i))*v1(i)));
u1(i+1)=u1(i)-(h*z1(i)*(u1(i)));
if y1(i+1)<0
break
end
end
w2=30;
u1(i+1)=0.7*100*cosd(w2);
v1(i+1)=0.7*100*sind(w2);
y1(i+1)=y1(i);
x1(i+1)=x1(i);
for k=i+1:1000
% position of the ball
% y-axi
y1(k+1)=y1(k)+h*v1(k);
%x-axis
x1(k+1)=x1(k)+h*u1(k);
% air resistance
z1(k)=((50*R.^2)/m) *(sqrt(u1(k).^2 + v1(k).^2));
% velocity in x and y
v1(k+1)=v1(k)-(h*(g+(z1(k)*v1(k))));
u1(i+1)=u1(i)-(h*z1(i)*(u1(i)));
end
Best wishes
Torsten.
Image Analyst
2016년 4월 1일
Torsten, post in your own answer so you can get reputation points if this works and she accepts and votes for your answer. You don't want to miss out on any credit you might get.
Mariam Sheha
2016년 4월 1일
Mariam Sheha
2016년 4월 8일
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!