开发者

i need to pick a random xy point from a list of xy points

开发者 https://www.devze.com 2023-01-23 04:48 出处:网络
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

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),:);
0

精彩评论

暂无评论...
验证码 换一张
取 消