MATLAB - 元胞数组到元胞
MATLAB - Cell array to a cell
我想创建一个 {1,2} 单元格数组,它将包含 {1,1} 中的单个单元格值和 {1,2}{:,1} 行中的多个单元格:
TEXT = {'-1';'432';'a';'c';'v';'-1';'-1';'14';'b';'n';'-1';'-1';'44';'m';'t';'r';'-1';'-1';'55';'o';'i';'u';'-1'};
Sections{1,1} = TEXT{5};
Sections{1,2}{:,1} = TEXT{3:10,1};
,但我得到一个错误:
The left hand side is initialized and has an empty range of indices.
However, the right hand side returned one or more results.
Error in fff (line 4)
Sections{1,2}{:,1} = TEXT{3:10,1}; % Text in the section
想法?
只需对 (n,2) 中的部分使用 ()
而不是 {}
:
TEXT = {'-1';'432';'a';'c';'v';'-1';'-1';'14';'b';'n';'-1';'-1';'44';'m';'t';'r';'-1';'-1';'55';'o';'i';'u';'-1'};
Sections{1,1} = TEXT{5};
Sections{1,2} = TEXT(3:10,1);
我想创建一个 {1,2} 单元格数组,它将包含 {1,1} 中的单个单元格值和 {1,2}{:,1} 行中的多个单元格:
TEXT = {'-1';'432';'a';'c';'v';'-1';'-1';'14';'b';'n';'-1';'-1';'44';'m';'t';'r';'-1';'-1';'55';'o';'i';'u';'-1'};
Sections{1,1} = TEXT{5};
Sections{1,2}{:,1} = TEXT{3:10,1};
,但我得到一个错误:
The left hand side is initialized and has an empty range of indices.
However, the right hand side returned one or more results.
Error in fff (line 4)
Sections{1,2}{:,1} = TEXT{3:10,1}; % Text in the section
想法?
只需对 (n,2) 中的部分使用 ()
而不是 {}
:
TEXT = {'-1';'432';'a';'c';'v';'-1';'-1';'14';'b';'n';'-1';'-1';'44';'m';'t';'r';'-1';'-1';'55';'o';'i';'u';'-1'};
Sections{1,1} = TEXT{5};
Sections{1,2} = TEXT(3:10,1);