How set scale limits of y-axis between 0-1 when values range from -9500 to 9200

조회 수: 3 (최근 30일)
Erin Browne
Erin Browne 2019년 3월 13일
답변: Yash 2025년 7월 18일
I have a large data set of relflectance values
I am trying to change these values in order for the min value to be respect of 0 and max 1 i.e. -9500 = 0 and 9200 = 1
I've tried the rescale function different way but still get it scaled were all my values are between 0.508 and 0.512 rather than spread between 0 - 1
does anyone know why or have code that can help?
Thank you
Erin

답변 (1개)

Yash
Yash 2025년 7월 18일
You can use the "normalize" function to do min-max scaling of your dataset to the range [0,1].
data = [-9500, -5000, 0, 5000, 9200]; % Sample data
disp(data);
-9500 -5000 0 5000 9200
normalized_data = normalize(data, 'range'); % 'range' rescales range of data to [0, 1]
disp(normalized_data);
0.0000 0.2406 0.5080 0.7754 1.0000
Refer to the documentation of "normalize" function here: https://www.mathworks.com/help/matlab/ref/double.normalize.html

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by