How can fix index exceeds matrix error
3 views (last 30 days)
Show older comments
BAHADIR Karba
on 30 Jan 2019
Commented: BAHADIR Karba
on 30 Jan 2019
mn=input('Modül Giriniz:');
T=input('Teeth Numbers :');
at=input('Transverse pressure angle: ');
ad=input('Addendum Coef: ');
de=input('Deddendum Coef :');
Hobtip=input('Hob Tip Radius coef: ');
rg=mn*T/2;
rr=rg-(de*mn);
br=rg*cosd(at);
tr=rg+(ad*mn);
b=(tr-br)/180;
r=br;
a=1;
r2=num2cell(br:b:tr);
inva=tand(at)-(at*pi/180);
ctt1=pi*mn/2;
% Involute Curves
while r<=tr
r=r+b;
a=a+1;
end
for i=1:1:a
teta{i}=acosd(br/r2{i});
invteta{i}=tand(teta{i})-(teta{i}*pi/180);
ctt2{i}=2*r2{i}*((0.5*ctt1/rg)+inva-invteta{i});
B{i}=0.5*ctt2{i}/r2{i};
x{i}=r2{i}*sin( B{i});
y{i}=r2{i}*cos(B{i});
leftx{i}=-1*r2{i}*sin(B{i});
end
% Trochoid Curves
B_tr=(de*mn)-(Hobtip*mn);
L=(pi*mn/4.0)-(B_tr*tand(at))-(Hobtip*mn/(cosd(at)));
W=((((pi*mn)/2.0)-L)/rg);
E=0;
e=E;
Emax=50*pi/180;
tro=Emax/179;
o=1;
E2=num2cell(0:tro:Emax);
while (e<=Emax)
e=e+tro;
o=o+1;
end
for q=1:o
Yz{q}=((rg-B_tr)*cos(E2{q}))+((rg*E2{q}*sin(E2{q})));
Xz{q}=(rg*E2{q}*cos(E2{q}))-((rg-B_tr)*sin(E2{q}));
DXZ{q}=(-(rg*E2{q}).*sin(E2{q}))+((B_tr*cos(E2{q})));
DYZ{q}=(B_tr*sin(E2{q}))+((rg*E2{q})*cos(E2{q}));
if(E==0)
A{q}=90*pi/180.;
end
A{q}=atan(DXZ{q}./DYZ{q});
Xt{q}=Xz{q}+((Hobtip*mn).*cos(A{q}));
Yt{q}=Yz{q}-(Hobtip*mn.*sin(A{q}));
Xtr{q}=Yt{q}.*sin(W)-Xt{q}.*cos(W);
Ytr{q}=Yt{q}.*cos(W)+Xt{q}.*sin(W);
leftXtr{q}=-1.*(Yt{q}.*sin(W)-Xt{q}.*cos(W));
end
% Tooth Curves
% Involute ones
plot(cell2mat(x),cell2mat(y));
hold on
plot(cell2mat(leftx),cell2mat(y));
hold on
% Trochoid Ones
plot(cell2mat(Xtr),cell2mat(Ytr));
hold on
plot(cell2mat(leftXtr),cell2mat(Ytr));
4 Comments
Luna
on 30 Jan 2019
Could you please define your inputs? So we can run your code?
mn=input('Modül Giriniz:');
T=input('Teeth Numbers :');
at=input('Transverse pressure angle: ');
ad=input('Addendum Coef: ');
de=input('Deddendum Coef :');
Hobtip=input('Hob Tip Radius coef: ');
Accepted Answer
Bob Thompson
on 30 Jan 2019
Your first error occurs with teta{i} = acosd(br/r2{i}); because r2 has one less element than the max values of i. I would suggest initializing a as 0 instead of 1.
I did not encounter the other errors.
More Answers (0)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!