With MATLAB, the straightforward way to compute the distance between two points is to compute the norm of the vector defined by the two points. You can use the MATLAB
norm(v) function that returns the Euclidean norm of vector v :
>> P1 = [1,2];
>> P2 = [2,4];
>> norm (P1 - P2)
This also works with 3D or even n-D points.