MATLAB Answers

Specific numbers generation Simulink

조회 수: 1(최근 30일)
Vasilis
Vasilis 16 Oct 2014
답변: Orion 18 Oct 2014
Hello. Is there any way to generate a sequence of specific numbers with a frequency of generation f_s for example?

  댓글 수: 0

Sign in to comment.

답변(2개)

Iain
Iain 16 Oct 2014
Matlab code for it would be something like... :
listofnumbers = [1 4 7 9];
weight = [1 2 3 4]; % weights, not frequencies... - 9 should appear 4x more than 1, 7 should be 3x, 4 should be 2x...
cw = cumsum(weight);
cw = cw./cw(end);
for i = 1:10
random = rand(1,1);
selected = listofnumbers(min(1:numel(listofnumbers) .* random < cw))
end

  댓글 수: 1

Vasilis
Vasilis 18 Oct 2014
Thanks for the answer. Is there a way to do the same thing using a block in simulink ?

Sign in to comment.


Orion
Orion 18 Oct 2014
Hi,
In the source library, use the Repeating Sequence Stair block.

  댓글 수: 0

Sign in to comment.


Translated by