The code is currently applied to solve Example 5.5 from Dynamics of Structures by A.K. Chopra, but the input parameters can easily be modified to solve any SDOF system. A yield point can be defined for a material which has been strained into the plastic zone. If this condition is met, then the Newton-Raphson iteration procedure for a particular time step will begin. The residual tolerance can be set for non-linear time steps. This algorithm does not take into account certain aspects of typical hysteresis loops or strain hardening/softening effects. It only works if the hardening constant of the material is 0 (which is unrealistic). It does, however, work in both directions, i.e., the material can yield in tension or compression.
It should be noted that, to avoid numerical errors and to have a clear description of the response, a timestep size should be chosen such that dt < T_n/10, where T_n is the natural period of the structure.
The algorithm used for the Newmark-beta method and for the Newton-Raphson method were obtained from: Chopra, A.K. (2014) Dynamics of Structures, Theory and Applications to Earthquake Engineering: Global Edition. Pearson Education. 4th ed.
Christopher Wong (2020). Newmark-Beta Method for Non-linear Single DOF Structures (https://www.mathworks.com/matlabcentral/fileexchange/71007-newmark-beta-method-for-non-linear-single-dof-structures), MATLAB Central File Exchange. Retrieved .
Just needed to edit the description. Did not change the code.