I'm programming in MATLAB and want to make my code as efficient as possible. But I'm encountering a problem.
I have a 3D matrix (row, column, heigth) And a 2D matrix (row, column)
I would like to save the max value of the height column in the corresponding cell of the 2D matrix. This can be done with a for-loop.
for i=1:row
for j=1:column
2D(i,j)=nanmax(3D(i,j,:));
end
end
But is there an other way too? Something like:
2D(mask)=3D(mask,nanmax(:));
with mask being a logical matrix, possible just containing ones to make it easier.
Any help will be greatly appreciated! Thanks Jasper