Answered step by step
Verified Expert Solution
Question
1 Approved Answer
We can model a trebuchet as a simple system of three masses on two linkages as shown in the sche- matic below. We will
We can model a trebuchet as a simple system of three masses on two linkages as shown in the sche- matic below. We will assume that the Trebuchet is already built and has a throwing arm that is 15 Im long, and a 3 m counterweight arm (13). It has a 10,000 Kg counterweight, and the effective arm mass m is 100 Kg. The initial throwing arm angle is 0 (t = 0) = -20 that is, the throwing arm is 20 off from being full vertical. You first have to tune the trebuchet for throwing a 50 Kg projectile. You can change the sling length, 12, and the initial sling gle, 0(t = 0), which can be between 0 and 180. You can also set the trigger angle 0* = 02-0 at which the sling releases the projectile. 1 The function must be called trebuchetSim It must take 4 input arguments: m, l2, 0 (t = 0), and 8*, in that order and in units of kilograms, meters, and degrees (not radians). It must output the horizontal and vertical position of the projectile relative to the axle of the throwing arm when the sling is released (u2x U2y), and the projectile's horizontal and vertical velocity, (v2x.Vzy) at this instant. These should be combined in a single array containing y = [Uzx, Uzy, v2x, V2y]. It must use ode 23 to perform the simulation. It must use default model parameters of: m = 100 Kg, m3 = 10,000 Kg. = 15 m, = 3 m, g = 9.8 m/s, and initial values for the state of the state of trebuchet of 8 (t = 0) = -20, w(t = 0) = 0, and w(t = 0) = 0. It must use ode 23 to perform the simulation. It must use default model parameters of: m = 100 Kg, m3 = 10,000 Kg. = 15 m, 4 = 3 m, g = 9.8 m/s, and initial values for the state of the state of trebuchet of 8 (t = 0) = -20, w(t = 0) = 0, and w(t = 0) = 0. It must call ode 23 with a simulation timespan of 3 s, but it must use the odeset command to set an events function that stops the simulation at the point that the sling angle relative to the throwing arm reaches its release angle, i.e. when 0-0 = 0. It must the odeset command to set ODE solver's MaxStep option to 0.01 s. Step 2: Build a MATLAB function called projectileSim to simulate the flight of the projectile until it hits the ground. This function should use ode 23 to follow the projectile in flight until it hits the ground and then return the horizontal distance from the trebuchet's axle to where the projectile landed. We will use the trebuchet's axle as the origin of our coordinate system as the tebuchet Sim function returns the location of the projectile relative to the axle when it is released. We will also assume that ground level is 20 m below the axle. This will use the same equation of motion as used for the football simulation in Lab 8. See the bonus video that I recorded for help on how to write the projectileSim function and the accompanying lecture code. The function must have the following attributes: The function must be called projectileSim. It must take 5 required input arguments: (1) the initial position and velocity of the projectile when it is released from the trebuchet as a single array [uzx, Uzy, Vzx. Vzy] in units of meters and meters per second, (2) the mass of the projectile m in kilograms, (3) the drag coeffi- cient d in N.s/m, (4) the gravitational acceleration g in m/s, and (5) the height of the ground relative to the axle of the trebuchet's throwing arm, h in meters. The code must return a single output: the horizontal distance in meters from the axle to where the projectile lands. The MaxStep option of the ODE solver must be set to 0.01 s. The function should use odeset to set an event function to terminate the simulation when the projectile strikes the ground. If either of the initial velocity components, 2x and v2y are negative the function should re- turn a distance of zero. If the projectile has not hit the ground after 1 minute of flight, also have the simulation stop and return zero. Step 3: Write a MATLAB function called computeRange that uses trebuchet Sim to compute the location and velocity of the projectile when it is released from the trebuchet and feeds these conditions into projectileSim to compute the distance the projectile travels. The function must be called computeRange. The function must take four input arguments: m, l, 0(t = 0), and the sling release angle * in units of kilograms, meters and degrees. The function must return a single argument: the distance in meters that the projectile travels. If either computeRange or trebuchetSim return an error, computeRange must return a distance value of zero. The function must use default model parameters of: h= -20 m (the ground is 20 m below the trebuchet axle), g = 9.8 m/s, and drag parameter of d = 0.01 N.s/m. Step 4: Write a MATLAB function called optimizeTrebuchet that optimizes 1. 0(0), and 0. for a given projectile mass m to maximize the range for a given projectile mass. Your function should use MATLAB's fminsearch command, to minimize the negative of the range computed by computeRange. You should watch the plots of the trebuchet motion that are generated as fminsearch calls computeRange to see what it is doing as it explores the trebuchet design- space. Your function should have the following attributes: The function must be called optimizeTrebuchet. The function must take wo input arguments: (1) The projectile mass m in kilograms, and (2) an array containing an initial guess for [12, 02(0), 0*] in units of meters and degrees. The function must return two output arguments: (1) The maximum range, and (2) an array containing the values of [1, 8(0), 0] that achieve this range. You should try running your optimization code starting from different initial values of [1, 0(0), 0]. Does the code always find the same optimal solution? Once you can optimize the trebuchet for a 50 Kg projectile, try changing the mass and see how that affects the optimal trebuchet setup [12. 02(0), 0]. You can also see how sensitive the range it small changes in [12, 02(0), 0*].
Step by Step Solution
★★★★★
3.44 Rating (163 Votes )
There are 3 Steps involved in it
Step: 1
To accomplish the tasks outlined we will follow a stepbystep approach writing MATLAB functions as described in the problem statement Lets break down e...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started