## How to modify for loop of i and j to get value odd number?

on 1 May 2013

### the cyclist (view profile)

```I2 = imread('......');
I2 = rgb2gray (I2);
N=8; %N= window size (8x8)
[L,L]=size(I2);
L2=L/N;
S=zeros(L,L);
```
```for i=1:L2
for j=1:L2
S=I2((i-1)*N+1:i*N,(j-1)*N+1:j*N);
theSum(i, j) = sum(S(:));
```
```end;
end;
```

Walter Roberson

### Walter Roberson (view profile)

on 1 May 2013

To get which value to be an odd number?

troy

### troy (view profile)

on 2 May 2013

I mean to access i and j to be odd number. i and j value will calculate odd number only. i=1,i=3,i=5......... j=1,j=3,j=5.........

## Products

No products are associated with this question.

### the cyclist (view profile)

on 1 May 2013

Do you mean, for example,

```i=1:2:L2
```

?

This would loop over i = 1,3,5, ..., L2

Walter Roberson

### Walter Roberson (view profile)

on 1 May 2013

Ooooo! I think you won today's Crystal Ball Award!

troy

### troy (view profile)

on 2 May 2013

yes...thanx =)

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

### Discover what MATLAB® can do for your career.

Apply Today

New to MATLAB?

Learn MATLAB today!