Question

How can I plot a figure in MATLAB such as a trapezium by giving only the vertices? I want the vertices connected by solid lines. I also want to calculate the area enclosed by the trapezium.

How can I do that?

Was it helpful?

Solution

use fill(x,y,colour)

fill([1,2,3,4],[6,3,4,9],"red")

or plot(x,y) with the first elements repeated at the end:

plot([1,2,3,4,1],[6,3,4,9,6])

Edit: for the area

polyarea([1,2,3,4],[6,3,4,9]) 

OTHER TIPS

There are many options for plotting.

plot, fill, patch would all be possibilities.

Use the function polyarea to give you the area specified by a set of vertices.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top