フィルターのクリア

Error with parfor loop

3 ビュー (過去 30 日間)
Mate 2u
Mate 2u 2012 年 2 月 20 日
Hi there, I am trying to run the following:
INPUT:
parfor i=1:1:5
data(i)=IBMatlab('action','query','symbol','EUR','localSymbol', 'EUR.USD', 'secType', 'cash', 'exchange', 'idealpro');
price(i)=data(1,i).bidPrice(1,1);
end
OUTPUT:
??? Error: The variable data in a parfor cannot be classified. See Parallel for Loops in MATLAB, "Overview".
Any help anybody? WHEN I USE NORMAL FOR LOOP IT WORKS.
  2 件のコメント
Mate 2u
Mate 2u 2012 年 2 月 20 日
The error is only coming from the line...
price(i)=data(1,i).bidPrice(1,1);
Oleg Komarov
Oleg Komarov 2012 年 2 月 20 日
The mlint message is already helping you.

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

採用された回答

Edric Ellis
Edric Ellis 2012 年 2 月 20 日
You need to ensure that you're indexing 'data' in a consistent manner inside the PARFOR loop. It should work to make both references either 'data(1,i)' or 'data(i)'.
  1 件のコメント
David Allen
David Allen 2012 年 6 月 11 日
To make this clear, as the help file is poor on this. You need something like this:
z(s).a= ....
z(s).b=.....
This one drove me mad.

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

その他の回答 (1 件)

David
David 2012 年 2 月 20 日
Have you tried pre-allocating "data"?
e.g.
data = struct('bidPrice',cell(1,5));
  1 件のコメント
Mate 2u
Mate 2u 2012 年 2 月 20 日
Hi that does not work, additionally I need it within the loop as I will be plotting as the loop iterations increase.

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by