Matlab extend plot over all axis range
I'm trying to use Matlab for some data plotting. In particular I need to
plot a series of lines, some times given two points belonging to it, some
times given the orthogonal vector.
I've used the following to obtain the plot of the line:
Line given two points A = [A(1), A(2)] B = [B(1), B(2)]:
plot([A(1),B(1)],[A(2),B(2)])
Line given the vector W = [W(1), W(2)]':
if( W(1) == 0 )
plot( [W(1), rand(1)] ,[W(2), W(2)])
else
plot([W(1), W(1) + (W(2)^2 / W(1))],[W(2),0])
end
where I'm calculating the intersection between the x-axis and the line
using the second theorem of Euclid on the triangle rectangle formed by the
vector W and the line.
My problem as you can see from the picture above is that the line will
only be plotted between the two points and not on all the range of my
axis.
I have 2 questions:
How can I have a line going across the whole axis range?
Is there a more easy and direct way (maybe a function?) to plot the line
perpendicular to a vector? (An easier and more clean way to solve point 2
above.)
Thanks in advance.
No comments:
Post a Comment