Ploting point according to a matrix

1 view (last 30 days)
Jens Christian Lassen
Jens Christian Lassen on 26 Mar 2017
Edited: Stephen23 on 27 Mar 2017
Hi data:
x=[1; 1; 3; 3; 2];
y=[1; 3; 3; 1; 2];
A=[0 1 0 1 0;1 0 1 0 1;0 1 0 1 1;1 0 1 0 0; 0 1 1 0 0];
I got some trouble plotting this. I got my XY point and need to plot it according to the matrix A. Cant seem to find any help on google and it's should be simpel but im not that good at mathlab
  7 Comments
Jan
Jan on 26 Mar 2017
@Jens: I assume, that your teacher gave you some lessons about Automotive Design, homogenous coordinates and adjecency matrices are used. Can you apply anything from what he has told you?
Joshua
Joshua on 27 Mar 2017
@Jens: Since this is homework I don't want to display a complete answer, but from what I read on Wikipedia, you want to draw a line between point i and point j if A(i,j)==1. If you input the x and y coordinates of c into vectors x and y respectively, you can plot the points using plot(x,y,'*'). From there you just need to use the line command. For example, line([x1 x2],[y1 y2]) would draw a line from point (x1,y1) to (x2,y2).
The drawing of lines can be done using an "if" statement in a "for" loop, inside another "for" loop. Try looking at Matlab documentation for the "if" command and for nested "for" loops. Good luck!

Sign in to comment.

Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

No tags entered yet.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!