点到曲线的距离怎么定义

img

直接用欧氏距离
你好,可以用fminsearch来求欧式最短距离

% 求最短距离
x0 = 2;
y0 = 1;
d = @(x)sqrt(((x-x0).^2+(1./x-y0).^2));
[xmin,dmin] = fminsearch(d,1);%搜索1附近的值
fprintf('最短距离=%.6f\n',dmin)

结果

最短距离=0.483052

然后也可以画图验证你求的结果

x = 0.3:0.01:3;
y = 1./x;
plot(x,y); hold on
plot([xmin,x0],[1/(xmin),y0],'r-o','markerfacecolor','r')
axis equal

img