How can I scales the entries of an array to the interval [0,1] in matlab version 2014a?

2 Ansichten (letzte 30 Tage)
How can I scales the entries of an array to the interval [0,1] in matlab version 2014a? The rescale function in matlab 2014a is not working for this purpose.

Antworten (2)

Walter Roberson
Walter Roberson am 23 Mai 2021
Use the deceptively named mat2gray() function.

DGM
DGM am 23 Mai 2021
Something like this:
A = rand(5)*10-4 % some random test array
A = 5×5
5.3835 -0.6412 4.3718 3.0501 4.8399 0.5035 2.0990 2.0365 0.5249 3.6086 1.7182 3.8267 -3.1955 4.3812 5.3857 -0.4145 -3.3937 -1.3723 2.9159 -0.8788 -3.1738 0.6271 -0.6550 3.2316 4.6812
mn = min(A(:));
mx = max(A(:));
B = (A - mn) ./ (mx-mn)
B = 5×5
0.9997 0.3135 0.8845 0.7340 0.9378 0.4439 0.6256 0.6185 0.4463 0.7976 0.5823 0.8224 0.0226 0.8856 1.0000 0.3393 0 0.2302 0.7187 0.2864 0.0250 0.4580 0.3119 0.7546 0.9198
That will scale the data such that its extrema correspond to [0 1]

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by