create cell from array with specified size
Show older comments
Hello,
Let mymatrix a 24x1 double, how is it possible to obtain a group as specified_sizex1 cell?
For example:
mymatrix=[1:24];
group={[mymatrix(1) mymatrix(2)],...}
Accepted Answer
More Answers (2)
Fangjun Jiang
on 19 Dec 2023
0 votes
num2cell(mymatrix)
2 Comments
Gaetano Pavone
on 19 Dec 2023
Fangjun Jiang
on 19 Dec 2023
mat2cell(mymatrix,[1],[6, 6, 6, 6])
mymatrix = (1:24).'
specified_size = 4;
assert(mod(numel(mymatrix),specified_size)==0, ...
'numel(mymatrix) is not a multiple of specified_size')
group = num2cell(reshape(mymatrix,[],specified_size).',2)
Categories
Find more on Array Geometries and Analysis 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!