Find index in 3D matrix for maximum value
12 次查看(过去 30 天)
显示 更早的评论
I have a 3D matrix 40X181X361, I want to find the index for the maximum value for each of the 40. Pp_loc gives me the 40 maximum values, I would like to find their indicies.
if true
% code
end
Xp = 10:50:2*Km;
Yp = 1*Km;
rho_p = sqrt(Xp.^2+Yp^2+HT^2);
FSPL_p = (4*pi*rho_p/lmda).^2; % Free Space Path Loss for Probe
Pp_dBm = zeros(length(Xp),length(thta),length(phi));
Pp_loc = zeros(1,length(Xp));
for pp = 1:length(Xp)
Pp_dBm(pp,:,:) = 30 + 10*log10((4*pi*abs(AF_Field_P).^2)/FSPL_p(pp));
Pp_loc(pp) = max(max(Pp_dBm(pp,:,:))); % Maximum Power at Probe
end
0 个评论
回答(1 个)
OCDER
2018-7-17
Here's one example to find maximum value in a 3D matrix called A
A = randi(100, 3, 3, 50)
[x, y, z] = ind2sub(size(A), find(A == max(A(:))))
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!