This 500 line MATLAB script automates the shaft design process for combined bending and torsion loads through iterative calculations. It dynamically incorporates stress concentration and material factors in each cycle, converging to an optimal diameter within five iterations. The tool streamlines a traditionally manual process reliant on chart lookups.