how to scale the array type double of range [-1,1] to [0,1] and [0,360] to[0,1]
조회 수: 5 (최근 30일)
이전 댓글 표시
i want to scale my values which are in range of [0,360], [-1,1]to [0,1]
댓글 수: 0
답변 (5개)
Jan
2013년 8월 16일
The following scales array x from any range to [0, 1]
scaled = x - min(x);
scaled = scaled / max(scaled);
댓글 수: 0
Alireza Ahani
2021년 2월 28일
check out this function. you can specify also the boundaries.
댓글 수: 1
Walter Roberson
2021년 2월 28일
Correct.
This function did not exist back when the question was asked, but is a useful function to know now.
In older days, the deceptively named mat2gray() function was the one to call to do the rescaling.
Azzi Abdelmalek
2013년 8월 16일
a=-1:0.1:1
b=a-min(a)
e=max(a)-min(a)
out=b/e
% you can use the same code for all cases
댓글 수: 0
Abdullah Caliskan
2017년 8월 14일
편집: Walter Roberson
2021년 2월 28일
if input is matrix, you can use this. upper, bottom
xmax =max(input);
xmin =min(input);
A=bsxfun(@minus,input,xmin);
B=bsxfun(@rdivide,A,(xmax-xmin));
cikis=B*(upper-bottom)+bottom;
댓글 수: 1
Jan
2017년 8월 28일
This works columnwise. I assume the min and max values should concern the complete matrix.
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!