次の関数は、中心点と勾配を指定して線を描画します。
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')