[英]Assign a row to cell array in Matlab?
我試圖像矩陣一樣這樣做:
>> line_params{1,:} = {numberPatterns{i}, lw, iw};
The right hand side of this assignment has too few values to satisfy the left hand side.
但是上面的錯誤。
類型如下:
>> class(line_params)
ans =
cell
>> size(line_params)
ans =
21 3
>> a={numberPatterns{i}, lw, iw};
>> class(a)
ans =
cell
>> size(a)
ans =
1 3
更改
line_params{1,:} = {numberPatterns{i}, lw, iw}
成
line_params(1,:) = {numberPatterns{i}, lw, iw}
(正常括號)。
如果使用花括號( {}
),則引用各個元素。 那是,
line_params{1,:}
將返回第一行中單元格line_params
中以逗號分隔的元素列表。 您不能將單元格數組(單個項目)分配給以逗號分隔的列表(多個項目)。
如果使用括號( ()
),則引用單元格條目,即將返回單元格數組。 並且您可以將單元格數組(單個項目)分配給另一個單元格數組(單個項目) - 前提是它們具有相同的尺寸。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.