Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clc
- clear all
- close all
- vB = 8; %m/s of bowler's run
- lArm = 0.8; %m of arm
- hBall = 2.4; %m height of ball at release
- I = 0.64; %kgm^2 mass moment of inertia of the arm
- m = 160; %g of ball
- r = 55; %mm of ball
- lPitch = 20; %m of cricket pitch
- R = 0.8; %coefficient of resititution between ball and pitch
- torq = input('The applied torque about the shoulder: ');
- angd = input('The angle with the horizontal axis at which the ball is released: ');
- Wd = torq * 225 * (pi / 180); %Work done is equal to kinetic energy
- omega = sqrt(2 * Wd / I); %rotational velocity
- vbB = lArm * omega; %velocity of ball relative bowler
- %Using Cosine Rule; calculating coefficients for vb terms
- A = 1;
- B = -2*vB*cosd(angd);
- C = vB^2 - vbB^2;
- rootsvb = roots([A B C]);
- for index1 = 1: numel(rootsvb);
- if isreal(rootsvb(index1))&&rootsvb(index1)>0
- vb = rootsvb(index1);
- break
- end
- end
- %Using Euler's Method
- tFinal = 20 / (vb*cosd(-angd)); %horizontal velocity remains constant
- %Total time to reach 20metres can be calculated
- num = 600; %Number of individual points on the plot
- %Increase num to increase accuracy, but plot takes longer to draw
- t = linspace(0, tFinal, num); %Vector of equally spaced time intervals
- deltaT = tFinal / num; %Distance between each time interval; smaller is more accurate
- a = [0; -9.81]; %Acceleration remains constant throughout
- v(:, 1) = [vb*cosd(-angd); vb*sind(-angd)]; %Components of initial velocity
- x(:, 1) = [0; hBall]; %Components of initial displacement
- %Creating animated plot
- figure
- h = animatedline;
- ax = gca;
- ax.XAxisLocation = 'origin';
- xlabel('Distance (metres)');
- ylabel('Height (metres)');
- axis([0 lPitch+1 -0.5 2.5])
- %Creating a for loop to generate displacements for each time point
- for ind = 1:num
- %Calculating the next displacement vector
- x(:, ind+1) = x(:, ind) + v(:, ind)*deltaT;
- if x(2, ind+1) > 0 %Checks if the ball is still in the air
- %Calculating the next velocity vector
- v(:, ind+1) = v(:, ind) + a*deltaT;
- else %The ball is in contact with the ground
- x(2, ind+1) = 0; %Defining the j component of displacement as 0
- %Calculating the j component of next velocity vector using
- %restitution
- v(:, ind+1) = [v(1, ind); -R*v(2, ind)+a(2)*deltaT];
- end
- %Drawing the next displacement vector
- addpoints(h,x(1, ind+1),x(2, ind+1));
- drawnow
- if x(1,ind+1) > 20 %If the distance is past 20 metres; the loop will stop
- break
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement