Question: This MATLAB computing project is due in around a week and I need some help on it. All the attachments are below, thanks. %-----------------------------------------------------------------------% Projectile
This MATLAB computing project is due in around a week and I need some help on it. All the attachments are below, thanks.

%-----------------------------------------------------------------------% Projectile (No Fluid Drag) % This program computes the motion of a particle subjected to % gravity forces and set in motion with initial velocity from an % initial position. Numerical integration (time stepping) is done % by the generalized trapezoidal rule (GTR). % % Student Posting ID: % Date: %----------------------------------------------------------------------clear; clc; %. Input physical problem data gravity = 9.81; e3 = [0; 0; 1]; mass = 2.0; % acceleration of gravity % unit vector in the "up" direction % mass of particle %. Initial conditions and analysis start and end times xo = [ 0.0; 0.0; 55.0]; % initial position of particle vo = [25.0; 15.0; 70.0]; % initial velocity of particle to = 0.0; % initial time (usually zero) tf = 12.5; % final time (end of analysis) %. Numerical analysis parameters dt = 0.01; % beta = 0.5; % eta = (1-beta)*dt; % zeta = eta^2 ; % nsteps = ceil((tf-to)/dt); % tf = nsteps*dt; % tol = 1.e-8; % itmax = 10; % analysis time step trapezoidal rule (GTR) parameter GTR parameter (defined for convenience) GTR parameter (defined for convenience) number of time steps in analysis adjust final time to discrete times Newton iteration tolerance maximum allowable Newton iterations %. Select figures to plot (1=yes, 0=no) dofig1 = 1; % 3D trajectory (static) dofig2 = 1; % Position components vs. time dofig3 = 1; % Speed vs. time comparison = 1; % Add comparison (exact) solution to figs %. % % % % Set up a history array to save results ever once in a while This part is simply to avoid plotting every point that we compute It does not take that many points to give a nice representative response curve. We need to compute more points to get accuracy in the solution. nitems = 11; % # of items in 'history' array nreport = 400; % # of steps to output to 'history' nsteps = ceil((tf-to)/dt); % # of analysis time steps nreport = min(nreport,nsteps); % don't report more than you compute noutput = ceil(nstepsreport); % set frequency of output history = zeros(nreport,nitems); % initialize storage for history %. Compute initial acceleration t = to; out = 0; iout = 0; its = 0; %. Initialize position and velocity (put in 'xold' and 'vold' arrays) xold = xo; vold = vo; %. Compute initial acceleration from the equation of motion aold = -gravity*e3; %. Compute motion by numerical integration--loop over time steps for i=1:nsteps %.... % % % % Write the values out to history, if appropriate This segment writes a row to 'history' every 'noutput' steps Note that for quantities that are not needed to advance the numerical solution (e.g., speed and xcomp) we only need to compute them if it is an output step. if (out==0) iout = iout + 1; speed = norm(vold); % Speed xcomp = xo + vo*t - 0.5*gravity*t^2*e3; % Classical solution history(iout,:) = [t,xold',vold',speed,xcomp']; out = noutput; end out = out - 1; %.... Compute the values for the next time step t = t + dt; err = 1; its = 0; bn = xold + vold*dt + beta*(1-beta)*dt^2*aold ; cn = vold + beta*dt*aold ; anew = aold; %... Newton iteration to compute the acceleration ac while (err
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
