Classification in Parfor Loops

parfor xIndex=1:2:c
for yIndex=1:2:c
x = xvec(xIndex);
y = yvec(yIndex);
M(xIndex, yIndex) = EscapeVelocity(-0.123+0.745*1i, x+y*1i, m);
end
end
MatLab says "The variable M in a parfor cannot be classified"
I would appreciate any explanation of why this occurs and how to correct it.

2 件のコメント

Walter Roberson
Walter Roberson 2013 年 2 月 16 日
Can your EscapeVelocity routine be rewritten to be vectorized, passing in an entire vector of y values at once?
Edwin
Edwin 2013 年 2 月 16 日
Yes it can easily, I think.

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

 採用された回答

Walter Roberson
Walter Roberson 2013 年 2 月 16 日

0 投票

Try constructing
xvec2 = xvec(1:2:c);
nxvec2 = length(xvec2);
yvec2 = yvec(1:2:c);
nyvec2 = length(yvec2);
M2 = zeros(nxvec2, nyvec2);
Then
parfor for xindex = 1 : nxvec2
x = xvec2(xindex);
for yindex = 1 : nyvec2
y = yvec2(yindex);
M2(xIndex, yIndex) = EscapeVelocity(-0.123+0.745*1i, x+y*1i, m);
end
end
Then
M(1:2:c, 1:2:c) = M2;

2 件のコメント

Edwin
Edwin 2013 年 2 月 16 日
As xvec and yvec were the same I have just made a general xvec. Selected parts of Code now read xvec2 = xvec(1:2:c);
n1 = length(xvec2);
M2 = zeros(n1, n1);
parfor xIndex=1:n1
for yIndex=1:n1
x = xvec2(xIndex);
y = xvec2(yIndex);
M2(2*xIndex-1, 2*yIndex-1) = EscapeVelocity2(-0.123+0.745*1i, x+y*1i, m);
end
end
Edwin
Edwin 2013 年 2 月 16 日
Got rid of the 2 and -1, they were from trying to mold your code to my uses. Thank you very much for your time.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeParallel for-Loops (parfor) についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by