correct use of randsrc function
조회 수: 7(최근 30일)
Scott MacKenzie 2021년 6월 9일
편집: Scott MacKenzie 2021년 6월 9일
There are lots of ways to do this, I suppose. Here's what I put together -- with a pesky twist. The weighting is built-in to the set. Just pull a value from set at random and the weighting is a natural outcome.
% define set
set = [-3 -1 -1 -1 -1 1 1 1 1 3];
% get random value from set (with built-in weighting)
Walter Roberson 2021년 6월 10일
randsrc() is from the Communications System Toolbox https://www.mathworks.com/help/comm/ref/randsrc.html
See https://www.mathworks.com/matlabcentral/answers/415418-how-to-correct-randsrc-in-matlab for some replacements.