- #1
supernova1387
- 31
- 0
Hi
I have a matrix a like below:
a=[1:19;2:20];
The minimum distance of these points from the line y=x can be calculated like this:
d=abs(-a(:,1)+a(:,2))/sqrt(2);
min(d)
using the equation of the distance of a point from a line:
d=abs(ax0+by0+c)/sqrt(a^2+b^2)
Now my problem is this:
I can find the distance of all the points from the line y=x easily and I can find the min distance but I don't know which point does this minimum distance refers to? I don't think this is difficult but I don't know the command. Something which after calculating the min distance tells me what is that point from matrix a
Thanks in advance
I have a matrix a like below:
a=[1:19;2:20];
The minimum distance of these points from the line y=x can be calculated like this:
d=abs(-a(:,1)+a(:,2))/sqrt(2);
min(d)
using the equation of the distance of a point from a line:
d=abs(ax0+by0+c)/sqrt(a^2+b^2)
Now my problem is this:
I can find the distance of all the points from the line y=x easily and I can find the min distance but I don't know which point does this minimum distance refers to? I don't think this is difficult but I don't know the command. Something which after calculating the min distance tells me what is that point from matrix a
Thanks in advance