Last updated on October 27th, 2012

I hate that I have to keep looking this up…

Here’s **how to scale or normalize your numbers in MATLAB so they lie between 0 and 1**.

Change the number of mins and maxs depending on the dimensionality of your matrix.

I = [ 1 2 3; 4 5 6]; % Some n x m matrix I that contains unscaled values.
scaledI = (I-min(I(:))) ./ (max(I(:)-min(I(:))));
min(scaledI(:)) % the min is 0
max(scaledI(:)) % the max 1 |

I = [ 1 2 3; 4 5 6]; % Some n x m matrix I that contains unscaled values.
scaledI = (I-min(I(:))) ./ (max(I(:)-min(I(:))));
min(scaledI(:)) % the min is 0
max(scaledI(:)) % the max 1

All of *scaledI* values are now between 0 and 1.

*Related*

Since you already have 0-1, multiply the resulting vector/matrix by 100.

Hello, how we going to rescale between the range of 0-100

thanks