how to normalize data between 0 and 1 , each column?

i have data that has 13 column and 194 row. i want to normalize each column between 0 and 1 and i want to use min_max method. what should i do? i don't know matlab a lot. plz help me. thank you.

 Respuesta aceptada

Stephen23
Stephen23 el 17 de Ag. de 2016
Editada: Stephen23 el 17 de Ag. de 2016
This will normalize each column (assuming no NaN, Inf, or complex):
x = [min(a,[],1);max(a,[],1)]
b = bsxfun(@minus,a,x(1,:));
b = bsxfun(@rdivide,b,diff(x,1,1))

6 comentarios

helia mb
helia mb el 17 de Ag. de 2016
thank you for answering but your answer is not correct i think. because i want each column separate, max-min it. i think the program you wrote will found max and done it to all matrix. can you help me with it?
Stephen23
Stephen23 el 17 de Ag. de 2016
Editada: Stephen23 el 17 de Ag. de 2016
@helia mb: Perhaps you should actually try my code before deciding what it does.
It does exactly what your question asked for: "i want to normalize each column between 0 and 1"
Here is max and min of each output column, and the first and last few rows too:
>> max(b,[],1)
ans =
1 1 1 1 1 1 1 1 1 1 1 1 1
>> min(b,[],1)
ans =
0 0 0 0 0 0 0 0 0 0 0 0 0
>> b
b =
0.00000 0.03662 0.05483 0.42490 0.51527 0.49898 0.75825 0.07069 0.04295 0.50102 0.24175 0.03286 0.13752
0.00528 0.04541 0.03632 0.57510 0.49080 0.59731 0.79402 0.06290 0.02609 0.40269 0.20598 0.02739 0.08263
0.01048 0.04101 0.05626 0.50980 0.53993 0.55680 0.78680 0.06572 0.04141 0.44320 0.21320 0.02427 0.07280
0.01613 0.06593 0.03987 0.61431 0.42952 0.57716 0.69051 0.07844 0.03759 0.42284 0.30949 0.05244 0.18548
0.02107 0.02637 0.06624 0.30725 0.41112 0.42447 0.58012 0.07350 0.06826 0.57553 0.41988 0.04930 0.27292
0.02640 0.04835 0.03560 0.56863 0.49080 0.58489 0.79677 0.06644 0.02531 0.41511 0.20323 0.03131 0.10015
0.03121 0.01978 0.02991 0.50980 0.44792 0.61299 0.75550 0.04524 0.02455 0.38701 0.24450 0.01331 0.04873
0.03599 0.01758 0.03205 0.41824 0.46632 0.53990 0.77476 0.05300 0.02455 0.46010 0.22524 0.01958 0.09669
0.04080 0.01978 0.01923 0.40529 0.40486 0.52300 0.73212 0.05654 0.01840 0.47700 0.26788 0.03131 0.17122
0.04584 0.03222 0.02919 0.56216 0.50313 0.62195 0.84182 0.05160 0.01689 0.37805 0.15818 0.01331 0.02157
0.05051 0.01171 0.02848 0.33333 0.41112 0.48025 0.70530 0.05654 0.02761 0.51975 0.29470 0.03052 0.18856
... etc
0.95864 0.04688 0.04344 0.50333 0.49080 0.53746 0.76616 0.07208 0.03375 0.46254 0.23384 0.03756 0.14214
0.96352 0.02343 0.03987 0.39863 0.44166 0.50835 0.70839 0.06078 0.03605 0.49165 0.29161 0.03131 0.16121
0.96844 0.02563 0.03062 0.45098 0.46007 0.54703 0.77098 0.05724 0.02379 0.45297 0.22902 0.02505 0.11364
0.97356 0.03662 0.02705 0.51627 0.43559 0.57288 0.74828 0.06078 0.02301 0.42712 0.25172 0.03209 0.13251
0.97896 0.05200 0.04771 0.52294 0.46632 0.54072 0.71527 0.07493 0.04141 0.45928 0.28473 0.04383 0.16795
0.98428 0.04760 0.06410 0.44451 0.46007 0.49002 0.65199 0.07917 0.05982 0.50998 0.34801 0.04930 0.21263
0.98940 0.03662 0.04628 0.35941 0.45399 0.44605 0.70289 0.07775 0.04141 0.55395 0.29711 0.04852 0.23767
0.99449 0.03516 0.04060 0.32686 0.45399 0.42264 0.72352 0.07987 0.03529 0.57736 0.27648 0.05087 0.25693
1.00000 0.05787 0.04060 0.53588 0.47847 0.53726 0.75928 0.07917 0.03221 0.46274 0.24072 0.04695 0.17257
helia mb
helia mb el 17 de Ag. de 2016
Editada: helia mb el 17 de Ag. de 2016
oh i try it. but i open normalized box by mistake . im really sorry sorry how can i use this new data? can you help me?
I have no idea what "i open normalized box" means. If you want to create a box plot, then you can simply do this:
boxplot(b)
helia mb
helia mb el 17 de Ag. de 2016
i really appreciate.....thank you :)))
helia mb
helia mb el 17 de Ag. de 2016
i want to use this new normalize data again. what ever thank you

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Preguntada:

el 17 de Ag. de 2016

Editada:

el 17 de Ag. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by