The work done (in Joule) to compress the piston shown in the figure is defined as:
W= s0∫snP(s)Ads
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:
Create a function file called trap_abc123.m that (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)
Create a source file called exam_abc123.m that calls the function for n = 1, n = 11, n = 21, n = 31, n = 41 and n = 51
Calculate the exact integration result 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
Plot the work done versus n and error versus n