The Euclidean distance between points p and q is the length of the line segment connecting them.
Does not improve on ipdm from the file exchange
You have removed your former submission and re-submitted it again with modifications. This procedure removed my comment also. Therefore I post it again:
Now you method to calculate the distance is more efficient. But you still define the inputs as matrices and reshape them to vectors afterwards. Is there any reason, why you do not define them as vectors directly?
It is still not clear why you assume, that this code is useful for others. A script with fixed inputs is not flexible. Converting this to a function would not be very useful also, because the built-in norm() command or the line
sqrt(sum((P_1D - Q_1D) .^ 2))
would be fast and clear already.
Therefore I still think, that this submission is neither useful nor usable.
Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.