I need to find the index of a 2d matrix within a 3rd array which has the lowest number of NaN values.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a 3D array of dimensions 942x523x365 with numerical and NaN values. I would like to find the 2D slice along the 3rd Dimension with the lowest number of NaN values.
0 Kommentare
Akzeptierte Antwort
Matlab Pro
am 16 Jun. 2024
HI @Angus
Here is a simpler example with lower dimentions..
Enjoy
M = randi([1,100],[5,10,15]);
idxNan = rand([5,10,15]) > 0.8;
M(idxNan) = nan;
% Horizontal max Nan's index
tmp = [sum(sum(isnan(M)))];
howManyNans = squeeze(tmp(1,1,:));
maxIdx = find(howManyNans == max(howManyNans));
% Vertical max Nan's index
M1 = permute(M,[3 1 2]);
tmp = [sum(sum(isnan(M1)))];
howManyNans = squeeze(tmp(1,1,:));
maxIdx = find(howManyNans == max(howManyNans));
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!