This function will read a *.gro file and extract information of atomid, molid, atomtype, x,y,z coordinates into an array in matlab.
Sumith YD (2020). Reading gromacs gro file in MATLAB (https://www.mathworks.com/matlabcentral/fileexchange/47975-reading-gromacs-gro-file-in-matlab), MATLAB Central File Exchange. Retrieved .
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.
Updated an archaic version with abilities to identify the type of the atom and coordinates in an efficient way.