How would I generate an n-sided shape wher n >= 4
Show older comments
Hello all,
I'm new to Matlab but I know a bit about programming.
For class, we have been asked to generate a matrix that gives the vertices of a two dimensional n-sided shape where n>=4. Then, generate the vectors to connect the vertices. We were also given a hint: a vector for each segment can be found by adding the vectors drawn from the origin to each of two adjacent vertices.
I know how to create a matrix using A = [1 1; 1 2; 2 2; 2 1] but I'm not sure how to draw the vectors given this or any other matrix.
The plot() function looks promising, but I'm unsure how to use it with the matrix.
Thank you for any suggestions.
Btw, I'm using 2011a
Accepted Answer
More Answers (1)
Roger Stafford
on 29 Nov 2013
0 votes
That hint "a vector for each segment can be found by adding the vectors drawn from the origin to each of two adjacent vertices" is incorrectly stated. Replace the word 'adding' by 'subtracting'. If P1 and P2 are two points (each represented by an array of two elements,) the vector pointing from P1 to P2 is P2-P1.
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!