Error_Unable to perform assignment because brace indexing is not supported for variables of this type

2 ビュー (過去 30 日間)
I am keep getting an error: Unable to perform assignment because brace indexing is not supported for variables of this type.
Can someone please help me out to resolve the error?
for i = 1:size(platemap,1)
S = zeros(size(platemap,1));
G = zeros(size(platemap,1));
[S{i,1},G{i,1}] = cellcyclestages('f',Data{i,1},params,opts);
end
Thank You
  2 件のコメント
darova
darova 2021 年 8 月 4 日
Because S and G are of double type numbers. THey are not of cell type
Tooba Jawwad
Tooba Jawwad 2021 年 8 月 5 日
Thanks for the input, how can I fix that?

サインインしてコメントする。

採用された回答

Image Analyst
Image Analyst 2021 年 8 月 5 日
What is Data? Hopefully it's a 2-D cell array. Or at least a 1-D cell array.
What does the cellcyclestages() function return? Two scalars? If so you don't need cell arrays. Vectors whose length may change from one iteration to the next? If so, then you need cell arrays.
See the FAQ for a nice discussion of cell arrays:
Try
numValues = size(platemap,1);
S = cell(1, numValues);
G = cell(1, numValues);
for k = 1 : numValues
[S{k}, G{k}] = cellcyclestages('f', Data{k,1}, params, opts);
end
  1 件のコメント
Tooba Jawwad
Tooba Jawwad 2021 年 8 月 7 日
Yes it is a 2D cell array data and two scalar cellcycle function return. Thank you I have fixed it!

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 8 月 5 日
Repaired code, no loop.
i = size(platemap,1);
[S{i,1}, G{i,1}] = cellcyclestages('f',Data{i,1},params,opts);
You do not need a loop because your existing code overwrites all of S and G every iteration of the loop, so your code only remembers what was done on the last iteration; so you might as well not any other iterations.
The recommended code would have been different if you were not overwriting all of S and G every iteration.

カテゴリ

Help Center および File ExchangeData Types についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by