I have an array of cells I want it to be converted into matrix of 2D

I did the following: 

```
B = [9 8 8 8 10 10 10 10 9 9];
A = [8,9,10]; 
Y = arrayfun(@(x) find(B==x),unique(A),'Un',0);

```

The result is: 

```
Y = {[2,3,4] , [1,10,9] , [5,6,7,8] } 

```

Now I want Y to be like this: 

```
 Y = 2  3  4  0  0 0 0 0 0 0 
     1  10 9  0  0 0 0 0 0 0 
     5  6  7  8  0 0 0 0 0 0 

```

a 2D matrix with rows of size A and columns of size B , How can I do that in MATLAB?