Based on the title of, the proposed code tends to simulate all the necessary result you need. It can also be used in 2D.
Zahra Sadeghi (2020). Truss simulation (https://www.mathworks.com/matlabcentral/fileexchange/57442-truss-simulation), MATLAB Central File Exchange. Retrieved .
Inspired by: Space Truss Systems as Linear Static Analysis, Matrix Structural Analysis, Truss Solver and Genetic Algorithm Optimzer, Truss Analysis, Add to mat, K-Fold Cross Validation, Cross validation sets, Teaching Learning Based Optimization for Truss Optimization, Matlab_Abaqus_25_Bar_Truss