dimanche 19 novembre 2023

How to pick a random number from a set of numbers in simulink?

I want to pick a number from a set of number, i.e [1011, 1001, 1111, 1101, 0011] once at the beginning of each simulation. But i am not getting any help from the random number generator blocks. MATLAB code works in this case, so I've used matlab fuction block to run the code in simulation. But the code keeps running and generating value. Is there any fix to this?

The code I'm using in the fuction block is:

numbers = [1011, 1001, 1111, 1101, 0011, 0101, 1100]; % Generate a random index index = randi(length(numbers)); % Display the random number data=(numbers(index));

tried many things. but either it is generating frequent random values or showing same value in every simulation from the set of numbers.




Aucun commentaire:

Enregistrer un commentaire