Is it possible to change the size of a cell in a cell array?

4 views (last 30 days)
If yes; then how do i do it?I created a cell array of dimensions (128,1) and the size of each cell is(4,1) as of now which i will have to change for getting an appropriate result. It would really feel to use some help.Thank you.
  1 Comment
Image Analyst
Image Analyst on 31 Aug 2015
You can stuff whatever you want into a cell and it blows away what used to be in there. What's the data type? Are all cells going to be the same size? If so, and they're numbers, why not just use a regular 2D matrix? Or if they're different sizes, a structure array? Are there going to be strings in the cells?

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 31 Aug 2015
... Yes?
X = repmat({1, 2, 3, 4}, 128, 1);
X is now a cell array of length 128 that contains cells that are 1 x 4 numeric.
You can now say
X{42} = {1, 2, 3, 3.1, 3.14, 3.141, 3.1415};
and now X{42} will be a cell that contains 1 x 7 numeric.

Tags

Community Treasure Hunt

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

Start Hunting!