File Exchange

image thumbnail

Reading gromacs gro file in MATLAB

version (1.7 KB) by Sumith YD
simple code for reading gro file


Updated 15 May 2018

View License

This function will read a *.gro file and extract information of atomid, molid, atomtype, x,y,z coordinates into an array in matlab.

Cite As

Sumith YD (2020). Reading gromacs gro file in MATLAB (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (3)

Sumith YD

comments of @Christoph are taken into consideration and updated the file. The new version can read file from any folder and also identifies the type of the atom.


This function indeed only works when in the same directory as the data, because the pathname that is returned by fullfile is simply ignored (use fullfile(pathname,filename)). Also, the type of the atoms is not returned. This would actually be a very useful. This can be done by looking up the name of the element in a dictionary. The type does not have to be a string, but one can identify the atom by its Z-number.

An Zou



Updated an archaic version with abilities to identify the type of the atom and coordinates in an efficient way.

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