MATLAB Answers

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

138 views (last 30 days)
preet
preet on 16 Aug 2013
Edited: Jan on 28 Aug 2017
i want to scale my values which are in range of [0,360], [-1,1]to [0,1]

  0 Comments

Sign in to comment.

Answers (4)

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

  0 Comments

Sign in to comment.


Jan
Jan on 28 Aug 2017
Edited: Jan on 28 Aug 2017
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);

  0 Comments

Sign in to comment.


Azzi Abdelmalek
Azzi Abdelmalek on 16 Aug 2013
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 Comments

Sign in to comment.


Abdullah Caliskan
Abdullah Caliskan on 14 Aug 2017
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 Comment

Jan
Jan on 28 Aug 2017
This works columnwise. I assume the min and max values should concern the complete matrix.

Sign in to comment.

Sign in to answer this question.

Tags