MATLAB: How to find distance between 2 atoms in a molecule and save it into the workspace using the BioInformatics Toolbox for MATLAB

atomicbioinformaticsBioinformatics Toolboxdistanceevalevalrasmolscriptmoleculemolviewerpdbreadpdbstructrasmolscriptviewer

I have looked up the demo on Visualizing the Three Dimensional structure of a molecule in the link below:
https://www.mathworks.com/help/releases/R2016b/bioinfo/examples/visualizing-the-three-dimensional-structure-of-a-molecule.html
In that demo, there is a portion named 'Measuring Atomic Distances' that has an example. The outcome of the example shows the distance on the Molecule Viewer. Is there a way to get this distance into the MATLAB workspace instead of displaying it on the figure?

Best Answer

This is not directly possible because evalrasmolscript executes the script using JMOL and does not return the value back. It instead displays the result in the molecule viewer. 
As a workaround, you may manually calculate the distance based on the coordinatees of the atoms. An example has been attached to demonstrate how this is done.