i need to pick a random xy point from a list of xy points
in mat lab if i read a data set into a new structure with an x and y value and now from that list i need to choose two开发者_高级运维 radom points from that data list of data there are like 400 points and i just need to choose two points so i can draw a line between the two points trying to do a least means of squares problem please help me
You can use RANDPERM to get a shuffled list of indices, then simply take the first two indices:
data = rand(400,2);
ind = randperm(400);
p1 = data(ind(1),:);
p2 = data(ind(2),:);
精彩评论