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?

有帮助吗?

解决方案

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;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top