![]() |
如何在MATLAB中从N点中随机选择一个点?
我使用以下代码创建和绘制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. [url=https://stackoverflow.com/questions/1816097]更多&回答...[/url] |
所有时间均为北京时间。现在的时间是 00:58。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.