Plotting a line between two points
Afficher commentaires plus anciens
Hi,
I am encountering a problem trying to plot a line between two points (x1, y1; x2, y2). I have a dataset with alternating columns of x- and y-coordinate data (e.g. in a 10 by 10 matrix), and I added two new columns (e.g. columns 11 and 12) whereby column 11 is the mean x-coordinate of columns 1, 3, 5, ... and column 12 is the mean y-coordinate of columns 2, 4, 6,...
A(:,11)=mean(A(:,1:2:9),2);
A(:,12)=mean(A(:,2:2:10),2);
I want to plot a line between each point and the average so I use this as an example:
plot([A(1,1) A(1,11)],[A(1,2) A(1,12)])
This should plot a line between the first x- and y-coordinate and the mean x- and y-coordinate of the first row. However, the error message that I am getting is
"Data must be a single matrix Y or a list of pairs X,Y"
The frustrating thing is I tried it with randomly generated integers e.g.
A=randi(100,10,10)
and it works, but on my dataset it doesn't. I also noticed that the numeric format of the two additional columns I created are different, and I wonder if that plays a part.
Any help is appreciated.
Thank you.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Annotations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!