how to scale the array type double of range [-1,1] to [0,1] and [0,360] to[0,1]

17 次查看(过去 30 天)
i want to scale my values which are in range of [0,360], [-1,1]to [0,1]

回答(5 个)

Jan
Jan 2017-8-28
编辑:Jan 2017-8-28
The general method to scale any input array (vector, matrix, multi-dim array) to the range [0, 1] is:
maxV = max(V(:));
minV = min(V(:));
Vs = (V - minV) / (maxV - minV);

Jan
Jan 2013-8-16
The following scales array x from any range to [0, 1]
scaled = x - min(x);
scaled = scaled / max(scaled);

Alireza Ahani
Alireza Ahani 2021-2-28
check out this function. you can specify also the boundaries.
  1 个评论
Walter Roberson
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
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

Abdullah Caliskan
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;

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by