How to Normalize 3D array with negative and positive values to values between -1 and 1?

Hi all
In order to be able to do some upcoming calculations, I need to normalize a 3D array to values between -1 and 1. The array (i.e.: 61 x 61 x 6) has values that can be negative and/or positive. Is there a fast way to normalize this complete array to values between -1 and 1, where -1 is the most negative value and +1 the largest positive value?
Actually I want to map the most negative number to -1 and the largest positive number to 1, and have all the numbers in between scale between them so the relations keep the same...
Greetings
Daan

 Accepted Answer

One approach:
A = randn(4, 4, 2) % Create Data
Amax = max(A(:));
Amin = min(A(:));
Range = Amax - Amin;
Anrm = ((A - Amin)/Range - 0.5) * 2; % Desired Result

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!