matrix - Plot the Centroid of a Dataset in Matlab -
in matlab have painted figure x1,y1,z1 axis using
h=plot3(x1,y1,z1,'y*');
and x1
,y1
, z1
row matrix shape. want highlight point (x,y,z)
consisting of average of each row matrix in same figure. how highlight average point in sharp or color , avoid being covered row matrix point. want source program matlab plot3()
.
so want highlight centroid of cluster. can following code.
x1 = rand(10,1); y1 = rand(10,1); z1 = rand(10,1); plot3( x1, y1, z1, 'y*' ); hold on; scatter3( mean( x1 ), mean( y1 ), mean( z1 ), 'r' ); hold off;
you can use scatter3
plot point in red using 'r' parameter. circles best job , won't covered hollow. can use different colors or markers built matlab.
here results
unless you're plotting trajectory, if plotting points, suggest use scatter3
instead of plot3
. gives following plot.
i suggest using blue instead of yellow better visibility.