Replacing zeros with ones in a 3D array & accessing all 2D arrays of the 3d array diagonally from bottom centre to the top of 2d arrays

Hello there,
I have a large 3d array and I would like to replace all zeros values by other constant values. Could you advise how to perform this?
Also, I would like to access all elements of the 2d array of my 3d array starting from the bottom centre and then go diagonally to the top of the 2d arrays, then, jump to the upper row from the bottom centre of all 2d arrays and perform the same thing.
Could you also advise on how to perform this in Matlab?
Thanks in advance, MT

 Accepted Answer

YourArray(YourArray == 0) = The_Constant;
If the constant is greater the value you are replacing and there are no values less than the constant in the array, then you can use
YourArray = max(YourArray, The_Constant);

1 Comment

Thanks Walter and so much appreciated for your answer, which solves the first part of the question.
Any suggestions for the second part of the question? Please see attached for more information about the second part of my question.

Sign in to comment.

More Answers (0)

Categories

Asked:

MT
on 20 Nov 2015

Edited:

MT
on 21 Nov 2015

Community Treasure Hunt

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

Start Hunting!