how to scale the array type double of range [-1,1] to [0,1] and [0,360] to[0,1]
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
i want to scale my values which are in range of [0,360], [-1,1]to [0,1]
0 commentaires
Réponses (5)
Jan
le 16 Août 2013
The following scales array x from any range to [0, 1]
scaled = x - min(x);
scaled = scaled / max(scaled);
0 commentaires
Alireza Ahani
le 28 Fév 2021
check out this function. you can specify also the boundaries.
1 commentaire
Walter Roberson
le 28 Fév 2021
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
le 16 Août 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 commentaires
Abdullah Caliskan
le 14 Août 2017
Modifié(e) : Walter Roberson
le 28 Fév 2021
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 commentaire
Jan
le 28 Août 2017
This works columnwise. I assume the min and max values should concern the complete matrix.
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!