# Version MATLAB 2020b: How can i convert an array to cell array with specific size?

1 view (last 30 days)
SM on 10 May 2021
Commented: SM on 10 May 2021
I have an array which is as follows:
MP1=[1 5 3 1 3 4 2 3 1 4 2 2 3 2 6 5 2 2 3 3 6 3 1 2 3 2 3 3 1 2 2 2 4 6 4 2 1 3 3 6 2 2 2 6 1 4 1 6 2 3 2 2 6 2 4];
This array needs to be convered to a cell of size (1 ,10) where each output in the cell should take values from MP1 sequentially and follow the size of each value in the following set:
Set=[6 5 5 5 6 6 5 5 6 6];
The final output will be:
output=[{[1 5 3 1 3 4]},{[2 3 1 4 2]},{[2 3 2 6 5]},{[2 2 3 3 6]},{[3 1 2 3 2 3]},{[3 1 2 2 2 4]},{[6 4 2 1 3]},{[3 6 2 2 2]},{[6 1 4 1 6 2]},{[3 2 2 6 2 4]}];
How can i do that?
Thanks!
##### 0 CommentsShow -2 older commentsHide -2 older comments

Sign in to comment.

### Accepted Answer

Matt J on 10 May 2021
output=mat2cell(MP1,1,Set)
##### 1 CommentShow -1 older commentsHide -1 older comments
SM on 10 May 2021
Appreciated!

Sign in to comment.

### Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!