Borrar filtros
Borrar filtros

parfor error with 3d matrix

1 visualización (últimos 30 días)
Ahmet Ayan
Ahmet Ayan el 5 de Mayo de 2019
Respondida: Walter Roberson el 5 de Mayo de 2019
I am a newbie with parfor use. Why does not the following run and give an error?
G=ones(11,11,5) ;
parfor i=1:10
v=zeros(1,5);
for j=1:5
v(j)=rand(1);
end
G(i,i,:)=v;
end

Respuesta aceptada

Walter Roberson
Walter Roberson el 5 de Mayo de 2019
The parfor index variable can only appear in one index position inside the body of the loop.
Create a 2D array and extend it after the loop
G = ones(11,11,5);
G2 = ones(11, 5);
parfor i = 1 : 10
v = zeros(1,5);
for j = 1 : 5
v(j) = rand(1);
end
G2(i, :) = v;
end
for i = 1 : 11;
G(i, i, :) = G2(i, :);
end

Más respuestas (0)

Categorías

Más información sobre Parallel for-Loops (parfor) en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by