I want to normalize just one column, how do i do that ?

4 Ansichten (letzte 30 Tage)
Diogo Costa
Diogo Costa am 20 Mai 2021
Beantwortet: Steven Lord am 20 Mai 2021
  1 Kommentar
Diogo Costa
Diogo Costa am 20 Mai 2021
The colum is the 12 that i want to normalize, i can't find a way to do a code that normalize one or specific columns without changing the others

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Steven Lord
Steven Lord am 20 Mai 2021
format shortg % Changing the display format to make the normalized matrix look nicer
M = magic(6)
M = 6×6
35 1 6 26 19 24 3 32 7 21 23 25 31 9 2 22 27 20 8 28 33 17 10 15 30 5 34 12 14 16 4 36 29 13 18 11
M(:, 4) = normalize(M(:, 4)) % Normalized with 'zscore'
M = 6×6
35 1 6 1.3716 19 24 3 32 7 0.4572 23 25 31 9 2 0.64008 27 20 8 28 33 -0.27432 10 15 30 5 34 -1.1887 14 16 4 36 29 -1.0058 18 11
M([1 3], :) = normalize(M([1 3], :), 2, 'center') % normalize so rows 1 and 3 have mean 0
M = 6×6
20.605 -13.395 -8.3953 -13.024 4.6047 9.6047 3 32 7 0.4572 23 25 16.06 -5.94 -12.94 -14.3 12.06 5.06 8 28 33 -0.27432 10 15 30 5 34 -1.1887 14 16 4 36 29 -1.0058 18 11
[mean(M(1, :)), mean(M(3, :))] % check -- should be close to 0
ans = 1×2
8.8818e-16 1.1842e-15

Weitere Antworten (1)

Jonas
Jonas am 20 Mai 2021
Bearbeitet: Jonas am 20 Mai 2021
use
data(:,12)=data(:,12)/max(abs(data(:,12)));
if your data in column 12 is not negative, then you can leave out the abs() function

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by