MATLAB: Euclidian distances between coordinates in pdb file

.pdbcoordinates

Hi everbody,
I want to calculate all the Euclidian from the pdb file. First of all, I extracted the lines that contains a specific element from the file.
After obtaining the element coordinates, I need the calculate all the Euclidian distances between two atoms(CA-CA) by x1, x2, x3 coordinates .For this, I have to use this formulation:
d =sqrt[(x1-x2)^2 +(x1-x3)^2+(x2-x3)^2], maybe with looping and I should obtain 76×76 matrix.
I attached the file. After that I need to plot all the entries of this matrix where the calculated
distance is <5.
I tried R studio, but I could not do this in R. Can you help for this?

Best Answer

Solution:
% euclid
filename = '1UBQ_CA.txt';
CA_CA = readtable(filename);
[iatom1,iatom2] = meshgrid(1:76,1:76);
distance = zeros(76,76);
distance_CA_CA = sqrt((CA_CA.x1(iatom1)-CA_CA.x1(iatom2)).^2 + ...
(CA_CA.x2(iatom1)-CA_CA.x2(iatom2)).^2 + ...
(CA_CA.x3(iatom1)-CA_CA.x3(iatom2)).^2);