The work done (in Joule) to compress the piston shown in the figure is defined as:
Where, Pressure, P(s) = k1 s + k2
Area, A = π r2
Radius, r = 5 x 10-2 m
k1 = 5 x 105 Nm-3
k2 = 105 Nm-2
s0 = 0 m
s1 = 5 x 10-2 m
Now answer the following questions using Matlab:
(a) Create a function file called trap_abc123.mthat (i) takes an input argument n, (ii) calculate the work done by integration using n segment trapezoidal rule and (iii) return the resulting work done.(Note: abc123 is your respective ID)
(b) Create a source file called exam_abc123.mthat calls the function for n = 1, n = 11, n = 21, n = 31, n = 41 and n = 51
(c) Calculate the exact integrationresult using Matlab symbolic tools and calculate the errors in calculating work done for n = 1, n = 11, n = 21, n = 31, n = 41 and n = 51
(d) Plot the work done versus n and error versus n