Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#1 |
高级会员
注册日期: 2019-11-21
帖子: 3,006
声望力: 66 ![]() |
![]()
我使用以下代码创建和绘制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. 更多&回答... |
![]() |
![]() |