Accepted Answer

dmin = min(data(:));
dmax = max(data(:));
scaled_data = (data - dmin)./(dmax - dmin) * 2 - 1;
or more simply,
scaled_data = mat2gray(data) * 2 - 1;
Multiply by 2 and subtract 1 is a very convenient mapping from [0 1] to [-1 1]

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!