フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Problem with parallel loops

1 回表示 (過去 30 日間)
Kian
Kian 2013 年 10 月 22 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Matlab does not let me to perform the following parfor loop as it warns me that valid indices for A is restricted. How can I overcome this? Any suggestions would be appreciated.
A = zeros(4,4);
a = [1 1 1 2 2 3];
b = [2 3 4 3 4 4];
parfor i = 1:6
A(a(i),b(i)) = corr(C(a(i),:),D(b(i),:));
end
C and D can be any matrices.

回答 (2 件)

Matt J
Matt J 2013 年 10 月 22 日
編集済み: Matt J 2013 年 10 月 22 日
If a and b are small
s=zeros(1,6);
Ca=C(a,:).';
Db=D(b,:).';
parfor i = 1:6
s(i) = corr(Ca(:,i).',Db(:,i).');
end
A=sparse(a,b,s,4,4);
If C and D are small,
s=zeros(1,6);
C=C.';
D=D.';
parfor i = 1:6
s(i) = corr(C(:,a(i).'), D(:,b(i)).');
end
A=sparse(a,b,s,4,4);

Kian
Kian 2013 年 10 月 23 日
Thank you Matt, I really appreciate your help.

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by