MATLAB: Normalize from -1 to 1… help me

1normalize

I have data like this ↓
temp Hum Atmosphere Wind.......
-10.2 50 101000 290 7.4 0 0 0
-11.5 47 101100 290 7 0 0 0
-12.5 44 101200 320 6.7 0 0 0
-13.1 43 101300 320 6.2 0 0 0
-13.3 43 101300 320 5.6 0 0 0
-13.5 43 101300 320 5.1 0 0 0
-13.1 44 101300 320 5.5 1 0 0
-12.9 44 101400 320 5.8 2 17 0.1
-12.7 44 101400 320 6.2 2 134 2.52
-12.9 41 101400 320 6.2 2 293 8.83
-13.1 39 101400 320 6.2 2 434 18.02
-13.3 37 101500 320 6.2 2 532 21.36
-13.9 34 101400 320 6.7 2 576 13.76
-14.5 32 101400 320 7.2 2 564 13.65
-15.1 29 101300 320 7.7 2 495 13.37
-14.9 31 101400 320 7.5 2 377 7.51
-14.7 34 101400 320 7.4 2 223 4.61
-14.5 36 101400 360 7.2 2 70 1.7
-14.5 37 101500 360 6.7 2 4 0.29
-14.5 39 101600 360 6.2 1 0 0
-14.5 40 101600 320 5.7 0 0 0
-14.5 40 101700 320 5.9 0 0 0
-14.5 40 101700 320 6 0 0 0
-14.5 40 101800 320 6.2 0 0 0
I wnat to normalize from -1 to 1.
I use the bsxfun, normalize, min, max …
But I can't.. Please help.

Best Answer

Let data be the column/row vector you want to normalize between -1 and 1.
clc; clear all ;
data = rand(100,1) ; % a random data
normalized_data = -1 + 2.*(data - min(data))./(max(data) - min(data));
Related Question