Your First Analysis¤
This tutorial builds a two-dimensional elastic truss, applies a static load, solves it in one step, and reads the displacement into MATLAB. It is intentionally small so that the complete OpenSeesMatlab workflow is visible in one place.
Create the interface¤
1 2 3 4 | |
opsMat owns the toolbox modules. ops is only a shorter reference to its .opensees command interface.
Define the model¤
The model has two translational degrees of freedom per node. SI units are used consistently in this tutorial.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
The vertical degree of freedom at node 2 is restrained because a horizontal truss alone provides no vertical stiffness.
Inspect the model¤
1 | |
For the interactive Polyscope backend, use:
1 | |
The regular plotModel plot is the simplest verification path. The Polyscope plotModel viewer is useful when you want an interactive GUI with visibility, display, slicing, and other viewer controls.
Apply the load¤
1 2 3 | |
Configure and run a static analysis¤
1 2 3 4 5 6 7 8 9 | |
OpenSees returns 0 when the requested analysis completes successfully. Always check the return code in scripts that will run unattended.
Read and verify the result¤
1 2 3 4 5 6 | |
nodeDisp returns a MATLAB scalar here. Larger workflows can store values in arrays, tables, structs, or files using normal MATLAB tools.
Clean up¤
1 | |
This clears the OpenSees domain. It is good practice at both the beginning and end of self-contained scripts.
Complete script¤
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
Next steps¤
- Learn MATLAB argument conventions in the OpenSees command interface.
- Use an ODB for time histories and response visualization in Pre/post-processing and visualization.
- Browse the examples for nonlinear, dynamic, structural, and geotechnical models.