## random generator on level of bytes

### Tessa Aus (view profile)

on 20 Jun 2019
Latest activity Commented on by John D'Errico

on 20 Jun 2019

### James Tursa (view profile)

I need to create a column using the randi function to generate random numbers that are divisible of 8 for bytes. Example: 512, 64, 128, 1048576.
Currently tried Data_Bytes = randi([8,1048576],8,1)
Obviously it does not give me items divisible by 8 and know I need to use the divisible(8) function but do not know how to combine the two for a successful output.
Thank you!

### James Tursa (view profile)

on 20 Jun 2019
Edited by James Tursa

### James Tursa (view profile)

on 20 Jun 2019

Generate random integers and then multiply them by 8 to guarantee that the result is divisible by 8. E.g., something like:
max_value = 1048576/8;
n = 8;
Data_Bytes = randi(max_value,n,1)*8;

John D'Errico

### John D'Errico (view profile)

on 20 Jun 2019
+1. The important thing to recognize is that you need to look at it from the right point of view. Instead of thinking about this as a problem of generating random numbers divisible by 8, think about generating random integers, and THEN multiply by 8. That insures the desired result.