如何在matlab中绘制一条直线的平分线?

时间:2013-02-21 00:41:57

标签: matlab

我正在尝试制作最小距离分类器,我需要画一条线的垂直平分线来绘制决策边界。我有一个点,甚至是平分线的斜率。如何在图表上绘制它?

1 个答案:

答案 0 :(得分:0)

以下函数将绘制一条给定中心点和斜率的线:

function drawLine(point,slope)
% point - vector [x,y]
% slope - slope of the line

x = point(1);
y = point(2);

lengthLine = 5;

xLine = x-lengthLine:x+lengthLine;
yLine = slope*(xLine-x) + y;

plot(x,y,'ro')
plot(xLine,yLine,'b')
相关问题