can anyone help me to run this code , thank you

1 次查看(过去 30 天)
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

采纳的回答

Walter Roberson
Walter Roberson 2019-4-10
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by