Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need to write a program in MATLAB but I dont even know where to start.. Please

ID: 3625901 • Letter: I

Question

I need to write a program in MATLAB but I dont even know where to start.. Please find problem below, I will give lifesaver and a lot of points to anyone that can assist me. Problem: You must write a MATLAB script that simulates a physical system where a mass is fired from a cannon with a given initial velocity. Taking into account the effects of drag and gravity you must plot the trajectory the projectile takes, determine how far it travels before hitting the ground and how long it was in the air. The projectile with a mass of 2 kilograms is fired with an angle of 35 degrees from the ground plane and has an initial velocity of 50 m/s. Assume the effect of gravity is given by the constant g = 9.8 m/s^2 and that the drag coefficient of the air is 2.5. We will assume the force caused by the drag of the air will be modelled by the simple Newtonian linear drag given by the following equation: Fd = -bv Where b is the drag coefficient and v ? is the velocity vector consisting of vertical and horizontal velocities You must simulate this system from 0 seconds onwards with a time step of 0.1s. You will have to evaluate the resultant force, acceleration, change in velocity and change in position for every time step and plot the X and Y positions for every time step until the projectile hits the ground. You must label the plot appropriately, give it a title and enable the grid. Finally you must report how long the projectile took to hit the ground and how far from the cannon the projectile hit the ground. Assume the projectile starts its flight at the origin.

Explanation / Answer

%Mass shot from a canon %initialize the constants mass = 2; %[kg] theta = 35*pi/180; %[rad] v0 = 50; %[m/s] g = 9.8; %[m/s^2] b = 2.5; %[N/(m/s)] dt = 0.1; %[s] %The forces acting on the body are (1) gravity and (2) drag %Set up the initial velocity vector v = v0*[cos(theta);sin(theta)]; %For this case, I will simply use a position vector x which has x and y components X = [0;0]; x(1) = 0; y(1) = 0; %supposing that the mass starts at the origin %initialize the counter and the time i = 1; time(i) = 0; %Start a while loop that checks to make sure the position vectors are OK. while(X(2) >= 0) %while we are still airborne (y>=0) i = i+1; %increment i time(i) = time(i-1)+dt; %Find the sum of the forces on the body Fgravity = mass*g*[0;-1]; %acts in negative y direction Fdrag = -b*v; %just use the equation they give you F = Fgravity+Fdrag; %add the forces a = F/mass; %find the instantaneous acceleration X = X+v*dt; %update the position %%OPTIONAL, depends on what problem is asking %%but here you can begin plotting the position in the X-Y plane %%by adding in the following command within the loop: %% plot(X(1),X(2),'x') %%which will give you a bunch of x's at each of the time steps %%until the mass hits ground x(i) = X(1); y(i) = X(2); %break down into components v = v + a*dt; %update the velocity end %The following takes the assumption that the plots are of x and y independently. %If you want a plot in the XY plane (not versus time) then I'll give alt's subplot(1,2,1); plot(time,x); title('x position vs. time'); xlabel('time, sec'); ylabel('x pos, m'); grid on; subplot(1,2,2); plot(time,y); title('y position vs. time'); xlabel('time, sec'); ylabel('y pos, m'); grid on; disp('The projectile took this many seconds to hit the ground:') time(i) %%ALTERNATIVELY, if you want the plot in the XY plane: %% plot(x,y); title('position tracking of projectile'); xlabel('x pos, m'); %% ylabel('y pos, m'); grid on; I hope that with the comments it will be easy enough for you to understand. Best of luck and have a happy Mother's day.