File Exchange

image thumbnail


version (1.32 MB) by Mikkel Pedersen
Imports ANSYS mesh and results data


Updated 04 Jul 2020

View Version History

View License

This function reads the mesh data for all structural elements listed below, but includes corner nodes only (i.e. disregards any midside nodes). Both displacement- and stress results are imported. All data is returned in the "model" struct as explained below. The function is intended for further postprocessing FE results in Matlab.
Before using the function, the ANSYS model must be exported to a text file. Use the supplied "export.mac" to do this. In Workbench, add a "Commands (APDL)" block under "Solution" and paste in the macro contents. In Classic, run macro by clicking "File>Read input from..." and selecting the "export.mac" file. This will create the file "model.txt" located in the ANSYS working folder:
where "ANSYS_WORK_DIR" and "JOBNAME" are names chosen by yourself.
Supported element types:
- SOLID187 (3D tetrahedral solid)
- SOLID186 (3D hexahedral solid)
- PLANE42, PLANE82, PLANE182, PLANE183 (2D 4/8-node quad/triangle)
- SHELL181, SHELL281, SHELL63 (3D 4/8-node shell)

INPUTS: path\filename of the ANSYS export file "model.txt" (string).

model.filename = path + filename of the model file
model.raw = raw tables from ANSYS
.etlist = element type list: [type_no, ansys_name, internal_type]
.nlist = node list: [node_no, x, y, z]
.elist = element list: [elem_no, type_no, mat_no, node1, ..., node8, com_x, com_y, com_z]
.flist = face list: [node1, node2, node3, node4, elem_no, centr_x, centr_y, centr_z]
.stress = stress results: [node_no, Sx, Sy, Sz, Sxy, Syz, Sxz]
.disp = displacement results: [node_no, Ux, Uy, Uz, Usum] = same as above, but containing surface nodes/elements only
.nlist = same as above, but containing surface nodes/elements only
.elist = same as above, but containing surface nodes/elements only
.flist = same as above, but containing surface nodes/elements only
.stress = same as above, but containing surface nodes/elements only
.disp = same as above, but containing surface nodes/elements only = maps between names and indices for nodes, elements and faces
.node2ni = node_no (externally referenced number) -> node index in nlist
.elem2ei = elem_no -> element index in elist
.face2elem = face index -> element name
.ni2face = node index -> face index
.ni2ei = node index -> element index

There are two sub-structs in output model: "raw" and "surf". The first contains the raw reading of data from the ANSYS export (ETLIST, NLIST, ELIST, PRNSOL,S and PRNSOL,U). The second contains the same, but for a reduced surface model, which is "scooped-out" such that only the surface nodes/faces of the elements are included. This is expedient to reduce the computational load of plotting solid models (i.e. not plotting the internal nodes/elements)

1) Planar model: mesh with node numbers and stress contours with deformed shape.
2) Solid model: showing a reduced (surface only) model.
3) Shell model: showing a 3D shell structure in deformed configuration.

Cite As

Mikkel Pedersen (2021). ANSYSimport (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (17)

Allen Yu

Great Job. Thank you!

twan van de weijer

Hi Mikkel, very nice tool! Do you have any plans for this function to support remote points also (174/170 elements)? Thanks!

Serhii Tetora

Jonathan Charron

Hi, for a 3D printing study I need to figure out how to pull just the shell data for n-layers. Can anyone help? I have limited to no FEA experience and am fumbling in the dark with ANSYS Academic, but, what I need is for every layer of a part, all the perimeter nodes (including features for holes etc preferably) XY coordinates and magnitude data for those points eg. for +/- stress. What sub functions do I need to call and how? I don't understand the difference between an element and a node... thanks

Mikkel Pedersen

Thank you T_K_86. Each of the appended examples show how to plot both stresses and deformation. It uses the function 'patch' in Matlab. Try following one of those.
BR Mikkel


Great Job Mikkel!
I was able to use your function, but how can I plot the mesh or the stresses or deformation?
Thanks a lot for your help!

Mikkel Pedersen

Thanks Timothy

I guess you can "disguise" the thermal results as stresses and use the script as it is. However, the script reads the export in a fixed-width format, so your thermal results must be written in the exact same format as the stresses. You can modify the exporting ANSYS macro - the line which currently says PRNSOL,S exports the stresses. Use *VWRITE command instead to create your own user defined output.

BR Mikkel

Timothy Polom

Thank you very much for this contribution. Any feeling if this could to plot steady-state thermal results in Matlab, for example?

Vinod Handi

I followed the above given steps but my system is not generating the required .txt file. Please help if anybody could guide me where I am going wrong.

Mikkel Pedersen

Thanks Federica

I think you can just add "190" (the ansys element no.) to the list in line 127. Then it will be imported like the other shell elements, however not with any of the special results for your particular element.

BR Mikkel

Federica Pierro

Thank you for the great work. Any tips on how to modify the script to include SOLSH190? Thank you.

Mikkel Pedersen

Thanks Mojtaba

I guess there is not really any problem in including midside nodes. However, there are no stress results for the midside nodes in ANSYS. The largest stresses are always in the corner nodes. Therefore, I didn't need them;-).

BR Mikkel

Mojtaba sharifi

thanks for valuable work. whats the problem for including midside nodes?

Mikkel Pedersen

Thanks Chris. The script currently handles a single load step only, but I'm sure you can make a loop in the ANSYS APDL export code snippet and another loop calling the import script in Matlab. Should be no problem.

Chris Wolf

Worked easily, didn't take much effort on my part. Any tips on how to modify to that it exports a time series of displacements when doing a transient analysis?

Mikkel Pedersen

Thanks Xiaoye

At the moment, the script cannot read the .rst. You need to use Ansys to export the results to a text file which can then be read by the script. Eventuelly, it would be nice to extract stuff directly from the .rst, but it is much more tricky to read a binary file.

BR Mikkel


This is a good job ! And if the function can read the '.rst' file, it must be a more prefect job. Thank you so much.

MATLAB Release Compatibility
Created with R2017b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Inspired by: Read ANSYS mesh

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!