我使用以下代码创建和绘制N点:
N = input('No. of Nodes:'); data = rand(N,2); % Randomly generated n no. of nodes x = data(:,1); y = data(:,2); plot(x,y,'*') hold on 我将如何随机选择其中一项?
回答:
randnum=ceil(rand(1)*N) %Sample a random integer in the range 0 to N your_node = [x(randnum),y(randnum)] %Here is the sampled node from your data set Edit: changed floor to ceil.
更多&回答...