Please write me the code.
When someone stands on a diving board, it bends, and the amount of deflection depends on factors such as the beam's length, cross-sectional shape, material properties, and the magnitude of the load. A cantilever beam, like the diving board, is a structure with one end fixed and the other end free. The deflection y (in meters) of the beam can be calculated using this equation:
y = (6 * F * E * (L^3) - x) / (2 * I * L)
where:
F = load (N)
E = modulus of elasticity (Pa)
I = moment of inertia (m)
L = beam length (m)
x = location of the deflection from the support (m)
Requirements:
Using M-files (both script and function files), calculate the deflection y in millimeters.
For the script file:
1. Ask the user to input F, E, I, L, and x one by one.
2. Display the deflection value to the user after all the parameters are entered using fprintf.
3. Ask the user if they want to try again or exit.
4. The script should run continuously until the user exits by entering 0.
For the function file:
1. The function should have five inputs and one output to the workspace.
2. The function should calculate the deflection if all the values entered are positive. Otherwise, the output will be 0 and display an error message.
Hint:
When F = 1000, E = 83 * 10^10, I = 444 * 10^-6, L = 10, and x = 4.25, y = 210 mm.