フィルターのクリア

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

1 回表示 (過去 30 日間)
debojit sharma
debojit sharma 2021 年 5 月 23 日
回答済み: DGM 2021 年 5 月 23 日
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.

回答 (2 件)

Walter Roberson
Walter Roberson 2021 年 5 月 23 日
Use the deceptively named mat2gray() function.

DGM
DGM 2021 年 5 月 23 日
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]

カテゴリ

Help Center および File ExchangeNumeric Types についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by