Question

Assume mtx to be the name of a n x m matrix. I would like that a cell of this matrix contain a list of elements.

For example,

mtx(2,3)={23, 45, 13}

mtx(1,5)={12}

The motivation behind this question is that I do not know the final length of the list and would like to add elements to the cell dynamically. How can I do it in matlab?

Was it helpful?

Solution

It's called a cell array. Now that you know how it's called, read the docs and it will be obvious.

Example:

mtx = cell(n, m);
mtx{2,3} = [23, 45, 13];
mtx{1,5} = 12;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top