以下函数将在给定中心点和斜率的情况下绘制一条线:
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')