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
1 个评论
Rik
2019-4-9
Have a read here (or here for more general advice). It will greatly improve your chances of getting an answer.
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!