Question:

Plotting a line and obtaining its coordinates in matlab!

by  |  earlier

0 LIKES UnLike

I'm trying to plot a line bewtween two point whose coordinates are defined by (max(ub1), max(vb1)) and (min(x11), min(y11)).

I have used the line command as follows:

h= line([max(ub1) min(x11)], [max(vb1) min(y11)]);

However I need to know some of the coordinated of the point that

create the line. Can anyone help please?

 Tags:

   Report

1 ANSWERS


  1. You can save the endpoints as variables:

    endpt_1 = [max(ub1),max(vb1)];

    endpt_2 = [min(x11),min(y11)];

    Not entirely sure what you're asking, but if you want to know points in the middle of the line, there are many ways to do that. For example, you can represent the line parametrically, like this:

    p0 = endpt_1;

    direction = (endpt_2-endpt_1);

    direction = direction/norm(direction);

    Then, you can sample it like this:

    n = 1000;

    t = linspace(0,1,n);

    pts = repmat(p0,[length(t),1]) + t(:)*direction;

    Now, the variable pts contains 1000 points on the line segment between your two endpoints.

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.