generating random numbers within a certain range & spacing
22 次查看(过去 30 天)
显示 更早的评论
if true
max=[6 7.75 8.75 9.25 9.50];
min=[5 6 7.75 8.75 9.25];
b=size(max,2);
n=20;
for i=1:b
c(i)=max(i)-min(i);
x=sort((min(i))+rand(n,1)*(c(i)), 'ascend')
y=(linspace(min(i),max(i),n))'
end
end
i want to create 20 random numbers for each c(i), but all the 20 numbers generated for each c(i) should maintain at least .025 gap among themselves. how do i do this? i cant do this with rand or linspace. anyone to help? :(
0 个评论
采纳的回答
Fangjun Jiang
2018-7-20
randi([200 240],[20,1])/4
11 个评论
Fangjun Jiang
2018-7-23
Please formulate your problem and ask a separate question. Keep in mind that this forum is for questions and answers, not for substitution of work.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!