How to generate random time series with specified max-min time intervals?
이전 댓글 표시
Hello,
I'd like to generate a time vector with random ascending values in which the interval between two adjacent values would be given by me, i.e. something like:
0 - min number in vector;
60 - max number in vector
0.5 - min interval between adjacent values
2 - max interval between adjacent values
Which would give something like : [0 0.7 1.8 2.4 ...... 59.1 60]
채택된 답변
추가 답변 (1개)
Andrei Bobrov
2013년 12월 6일
편집: Andrei Bobrov
2013년 12월 6일
One way
d = .5 + 1.5*rand(70,1);
d2 = [0;cumsum(d)];
out = [d2(d2 < 60 - .5);60];
댓글 수: 3
Jos (10584)
2013년 12월 6일
Note that this might give an erroneous result as the vector d2(d2<60) could have a last value that differs less than 0.5 from 60 ...
Jos (10584)
2013년 12월 6일
A quick fix would be out = [d2(d2 < (60-0.5) ; 60] ; but this would abort true randomness, which might or might not be an important issue here ...
Andrei Bobrov
2013년 12월 6일
편집: Andrei Bobrov
2013년 12월 6일
Hi Jos! Thanks for your comments. Corrected.
카테고리
도움말 센터 및 File Exchange에서 Random Number Generation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!