Shown below is a published version (PDF format with appended graphs from output and command window) of the MATLAB code. The comments guide the reader on what is being computed and how to analyze it. The example case shown below utilizes piston links and sizes appropriate for system integration, hence the smooth sinusoidal movement curve of a piston. Below the code is an attached figure of a system with incorrect sizing.

The inflection/crossover alignment portion shows where the piston will receive additional friction from the system due to a change in inertia via sudden change in direction (e.g. when it reaches TDC or BDC). At these points we expect the piston to catch, or expect the input torque to increase slightly to retain the same velocity.


Figure 1 shows a Piston Kinematics Analysis where the links are sized incorrectly, causing both constrained motion which makes the piston take an unexpected trajectory (i.e. at the top of its stroke, the piston dithers before coming back down as shown from crank angle ~130 to ~230). This is akin to a slider crank that's been correctly sized but has incorrect valve timing. The crash of the valve and piston creates a similar obstructive motion and forces the piston trajectory to slow, shown by the impulse velocity where the contact occurs.

Figure 1: Incorrect Slider Crank Link sizing