how to start with 0 (zero) in for loop?

65 次查看(过去 30 天)
for i = 1:n_slice
x(i) = i*deltar;
R(i) = x(i)+rb;
% Evaluate the pressure angle at Ri
theta(i) = acos(rb/R(i));
%Evaluate the involute angle at Ri
inv_ang(i)= tan(theta(i))-theta(i);
% Evaluate the Circular Tooth Thickness at Ri
ctt(i) = (2.*R(i))*((0.5*cptt/rp) + theta_pitch - inv_ang(i));
B = 0.5*(ctt(i)/R(i));
%Eventually, Coordinates might be evaluated
X(i) = R(i)* sin(B);
Y(i) = R(i)* cos(B);
plot(X(i),Y(i),'-r',X(i),Y(i),'+b','LineWidth',2,'MarkerSize',3)
plot(-X(i),Y(i),'-r',-X(i),Y(i),'+b','LineWidth',2,'MarkerSize',3)
end
WHEN I START WITH 0 (ZERO) IT GIVES ERROR. BUT I NEED TO START WITH ZERO NOT 1 !!!

采纳的回答

Thorsten
Thorsten 2015-11-25
Use
for i = 1:n_slice+1
x(i) = (i-1)*deltar;
  1 个评论
Ender Rencuzogullari
but I wonder why matlab does not allow to start from 0? and is there any different way to do it?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by