Variable classification in Parfor loop

1 回表示 (過去 30 日間)
Tristan
Tristan 2013 年 6 月 26 日
Hi all -
I know this type of question has been asked many times, but I simply can't figure out how to translate my code to work. Very simply: - I have a large cell called "masterData", which merely holds my final data - In a parfor loop, I am performing an analysis that yields three large arrays rt, xo, and no. - I'd like to store the three large arrays in the masterData cell together with the sample name:
masterData=cell(20,1);
parfor i=1:20
%analysis here. Yields rt, xo, no
masterData{i,1:4}={name rt xo no};
end
I get the error "Error: The variable masterData in a parfor cannot be classified." I'm sure this is an easy fix relating to how masterData is populated. Any help is appreciated. Thanks,
Tristan

採用された回答

Sean de Wolski
Sean de Wolski 2013 年 6 月 26 日
rt = 3;
xo = pi;
no = 2;
name = 'Sean';
masterData=cell(20,4);
parfor i=1:20
%analysis here. Yields rt, xo, no
masterData(i,:)={name rt xo no};
end
You index into masterData with columns 1:4 and curly braces yet the preallocated cell is a 20x1.
The 1:4 cannot be used because of this:
Form of Indexing. Within the list of indicesfor a sliced variable, one of these indices is of the form i, i+k, i-k, k+i,or k-i, where i is the loopvariable and k is a constant or a simple (nonindexed)broadcast variable; and every other index is a constant, a simplebroadcast variable, colon, or end.
  1 件のコメント
Tristan
Tristan 2013 年 6 月 26 日
Thanks!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by