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

# i've an image of size 204x204. after dividing the the image into overlapping blocks,then m using mat2cell i got the following error

Asked by pammy on 12 Feb 2013

whos I;

fun=@(block_struct) mean2(block_struct.data(:));

B=blockproc(I,[6 6],fun,'bordersize',[3 3]);

C=mat2cell(B,[6 6],[6 6]);

error: =>

Input arguments, D1 through D2, must sum to each dimension of the input matrix size, [0 0].'

error in mat2cell

can u tell what is my mistake n plz rectify it...as soon as

## 1 Comment

pammy on 12 Feb 2013

plz tell me whats wrong with the above code...

## Products

No products are associated with this question.

Answer by Walter Roberson on 12 Feb 2013

```C=mat2cell(B,[6 6],[6 6]);
```

the second argument must add up to size(B,1), and the third argument must add up to size(B,2).

Also, somehow, your B has come out empty, size 0 x 0, perhaps because you did not use the blockproc options 'TrimBorder', false

pammy on 12 Feb 2013

sir u mean C=mat2cell(B,size(B,1),size(B,2));

is it correct or not?

if not plz rectify it

Walter Roberson on 12 Feb 2013

No it is not correct.

```C = mat2cell(B, [6 6 6 6 6 6 ... 6], [6 6 6 6 .... 6], size(B,3));
```

where the first group of 6's has enough 6's to add up to size(B,1) and the second group of 6's has enough 6's to add up to size(B,2)

Answer by Jan Simon on 12 Feb 2013

The dimensions in your MAT2CELL call do not match the size of the input B, which seems to be empty.

Walter Roberson on 12 Feb 2013

What would you do with the over 4500 individual B variables if you had them? Are you planning to code all 4500+ different variable names into your code? And it's going to be obvious to the reader of the code what variable B138 means, and it is going to be obvious that B129 is not in the same row as B128 ?? Please reconsider using individual variable names.

http://matlab.wikia.com/wiki/FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F

Image Analyst on 12 Feb 2013

mat2cell does not do overlapping blocks/tiles. They are adjacent (touching) but NOT overlapping. You have to decide what you want: tiling with overlapping or tiling without overlapping.

Walter Roberson on 12 Feb 2013

When blockproc() is called with Bordersize, and with TrimBorder set to false, and if the fun returns something the same size as the data structure member passed into the fun, then the returned array will consist of adjacent tiles expanded out of the overlapping data.

```1 2 3 | 4 5 6 7 8 9 | 10 11 12 || 7 8 9 | 10 11 12 13 14 15 | 16 17 18 || 13 14 15 | 16 17 18 19 20 21 | 22 23 24 ||
```

In the above, the single-| mark the logical edges of the core of the tiles, with the overlap region to the left and right of there; the double-|| mark the logical edges of what was returned by fun and thus the places at which mat2cell should be used to break up the array. The bars have just been added for education purposes here and do not exist in the array; the array itself would look like

`   1 2 3 4 5 6 7 8 9 10 11 12 7 8 9 10 11 12 13 14 15 16 17 18 13 14 15 16 17 18 19 20 21 22 23 24`