1

I want to create a random array with values between 0 to 255 but without any looping value, like (0: 255) but its value is scrambled. how to do it?

output like

32, 204, 16, 92, ...
1

3 Answers 3

2

With really random and possibly repeating numbers:

randi(256,1,256)-1

Every value occuring exactly once, random permutation:

randperm(256)-1
Sign up to request clarification or add additional context in comments.

Comments

0

Use the randperm function.

result = randperm(255);

Comments

0

I am not sure what you mean by looping but if you want a random array with values between 0 and 255 uniformly distributed you can do this:

a = floor(256*rand(1,10000));

This will give you an array with 10000 values uniformly distributed between 0 and 255

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.