can anyone help me to run this code , thank you

1 visualización (últimos 30 días)
mina massoud
mina massoud el 9 de Abr. de 2019
Respondida: Walter Roberson el 10 de Abr. de 2019
for i=1:300
for j=1:100
A{i,j}=10*randn(2,8);
B{i,j}=10*randn(2,8);
MA{i,j}=mean(A{i,j},1);
MB{i,j}=mean(B{i,j},1);
[E{i,j}, idx{i,j}] = min([MA{i,j};MB{i,j}]);
AB{i,j} = nan(2, length(E{i,j}));
AB{i,j}(:,idx==1) = A{i,j}(:,idx==1);
AB{i,j}(:,idx==2) = B{i,j}(:,idx==2);
end
end
  1 comentario
Rik
Rik el 9 de Abr. de 2019
Have a read here (or here for more general advice). It will greatly improve your chances of getting an answer.

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 10 de Abr. de 2019
for i=1:300
for j=1:100
A{i,j}=10*randn(2,8);
B{i,j}=10*randn(2,8);
MA{i,j}=mean(A{i,j},1);
MB{i,j}=mean(B{i,j},1);
[E{i,j}, idx{i,j}] = min([MA{i,j};MB{i,j}]);
AB{i,j} = nan(2, length(E{i,j}));
AB{i,j}(:,idx{i,j}==1) = A{i,j}(:,idx{i,j}==1);
AB{i,j}(:,idx{i,j}==2) = B{i,j}(:,idx{i,j}==2);
end
end

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by