2013-02-21 365 views

回答

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')