我想操作一个元胞数组并使元胞数组的某些索引包含空矩阵[]
。我似乎无法弄清楚如何做到这一点:
>> yy=num2cell(1:10)
yy =
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10]
>> yy{1:2:end}=[]
??? The right hand side of this assignment has too few values to satisfy
the left hand side.
>> yy(1:2:end) = []
yy =
[2] [4] [6] [8] [10]
呸! 似乎不能做我想做的事。我想在单元格数组中留下空元素,例如
[] [2] [] [4] [] [6] [] [8] [] [10]
有什么建议么?我的索引向量可以是任意的,可以是索引形式或布尔形式,不一定是 [1 3 5 7 9]。