MATLAB Draw a polygon from line equation

  • Thread starter minhduc515
  • Start date
I'm trying to draw a quadrilateral in matlab. I has 4 line equations.
Can i draw that polygon, using line equations ? I knew matlab can draw polygon from coordinates, but i don't want to use it.
 

Wrichik Basu

Gold Member
2018 Award
1,063
935
You're saying that you want to draw a quadrilateral, and you have the equations of the four sides. Then just plot those lines, and they should intersect to give you the quadrilateral. Use the plot or fplot functions to plot the lines. Remember to use hold on between drawing the graphs.
 
Yes, i tried, but i dont want to have leftovers between two lines
 

Wrichik Basu

Gold Member
2018 Award
1,063
935
Yes, i tried, but i dont want to have leftovers between two lines
Are you saying that you don't want the sides be extended? In that case, you'll have to solve two equations at a time and find the coordinates of the four vertices. Then draw the lines from one vertex to the other, i.e. range ##x## from one vertex to the other, find ##y## for intermediate points, and plot.


If you give the four equations, I can help you start.
 
This is my polygon. a,b,Z are constants
I think it's hard to find intersect between lines, so it's the reason why i dont want using coordinates to plot
240772
 

Wrichik Basu

Gold Member
2018 Award
1,063
935
This is my polygon. a,b,Z are constants
I think it's hard to find intersect between lines, so it's the reason why i dont want using coordinates to plot
Two small questions: 1. One axis is X, the other is y or R? 2. Is everything other than x and you a constant (including z)?
 
1. One axis is X, the other is R
2. Z, b and a are constant
 

Orodruin

Staff Emeritus
Science Advisor
Homework Helper
Insights Author
Gold Member
2018 Award
15,759
5,758
I think it's hard to find intersect between lines
Finding the intersection between two lines is just a matter of solving a trivial linear system ...
 

Wrichik Basu

Gold Member
2018 Award
1,063
935
Finding the intersection between two lines is just a matter of solving a trivial linear system ...
And it can be done using solve function.

To the OP: that's what you have to do. I can't connect to matlab currently from my phone (I have poor network), so I cannot try at this moment. Your variables are ##x## and ##R##. Use the above function to solve the equations.
 

Want to reply to this thread?

"Draw a polygon from line equation" You must log in or register to reply here.

Related Threads for: Draw a polygon from line equation

Replies
13
Views
14K
Replies
4
Views
5K
Replies
6
Views
18K

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving
Top