I have a problem where I have to integrate a vector to get another vector. (this problem related to noncircular gear design).

I am trying to find phi 2 the output angle depending on the integration in equation 2.4.5.

I know that the last value of phi 2 should be pi=3.14 almost. but when I am using cumtrapz function as in the code down, the values of phi 2 is not ok.

I think that because of the approximation of the function (cumtrapz), isn't it?

is there any methodolgy or another function to numerically integrate the vector.

please help.

`% this program is for calculating the NCG (non-circular gear) with no approximation`

clear, clcdisp('This program generates NCG depending on the imported speed ratio form Excel file')disp('and entered center distance')Ratio=xlsread('speed_ratio.xlsx','A:A');Ratio=Ratio';Center_dis=89.305;m=3;disp('*')disp('*')disp('The solution depends on the main equation of NCG design and geanaration')disp('*')disp('*')% the input angle is equal parts since the driving gear angular velocity is

% constant, so depending on the number of the speed ration elements, we

% can divide the one rotation (2*pi) to the same number of elements

Input_ang=0:0.0001*pi:2*pi;% plot the speed ratio variations

figure(1)% plot the center

plot(0,0,'or','LineWidth',5)hold onplot(Input_ang,Ratio,'LineWidth',3)title('The speed ratio variations of the NC-gearset')xlabel('input angle')ylabel('W_2/ W_1')axis equalgrid on% generating the first centrode with its evolute, base curve, tip and root curve.

R_c1=(Center_dis)./(1+Ratio);X_c1=R_c1.*cos(Input_ang);Y_c1=R_c1.*sin(Input_ang); % plot it with clear zero point

figure(2) % plot the center plot(0,0,'or','LineWidth',5) hold on plot(X_c1,Y_c1,'k') title('The first centrode') xlabel('X') ylabel('Y') axis equal grid on% generating the second centrode with its evolute, base curve, tip and root curve.

% R_c2=Center_dis-R_c1; % first choice

R_c2=(Center_dis.*Ratio)./(1+Ratio); % second choice

% finding the rotating angle of the second gear >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> here is my problem >>>>> the last value of this output angle must be equal to -pi

Ratio_2=1./Ratio;out_ang_trap=cumtrapz(Input_ang,Ratio_2);out_ang_trap=pi-out_ang_trap;X_c2=R_c2.*cos(out_ang_trap);Y_c2=R_c2.*sin(out_ang_trap); % plot it with clear zero point figure(3) % plot the center plot(0,0,'or','LineWidth',5) hold on plot(X_c2,Y_c2,'k') title('The second centrode') xlabel('X') ylabel('Y') axis equal grid on

## Best Answer