MATLAB Answers

## Generating random blocks of 7-by-7 pixels from a multidimensional array 700 x 800 x 6.

Asked by Chandrama Sarker

### Chandrama Sarker (view profile)

on 18 Jul 2017
Latest activity Commented on by Walter Roberson

### Walter Roberson (view profile)

on 18 Jul 2017
Accepted Answer by Walter Roberson

### Walter Roberson (view profile)

Hi, I am new in the programming field and encounter a problem while coding to generate 100 random blocks of 7x7 pixels from a multidimensional array with a size of 700x800x6.Any help in this regard will be highly appreciated

#### 0 Comments

Sign in to comment.

## 1 Answer

### Walter Roberson (view profile)

Answer by Walter Roberson

on 18 Jul 2017
Accepted Answer

Easy way: loop
Trickier way:

Chandrama Sarker

### Chandrama Sarker (view profile)

on 18 Jul 2017
Thanks, Walter, I will try in a trikier way. I have tried the loop for it but found it a bit complicated as my knowledge in this field is very new. I will let you know how far I will go with my next try.
Walter Roberson

### Walter Roberson (view profile)

on 18 Jul 2017
The trickier way is not recommended for beginners!
for K = 1 : 100
r = randi(700-6,1,1);
c = randi(800-6,1,1);
rb{K} = YourData(r:r+6, c:c+6, :);
end

Sign in to comment.