1
$\begingroup$

I need some help in normalizing my matrix. I have a 5X4 matrix A. I want to normalize each column. Following is the explanation on the operations

B = Operation of matrix (A)

B matrix is 5x4 matrix. B(ij) = (A(ij)-mean of Jth column of A)/(Standard Deviation of Jth column of A)

I need to do it using matrix operations only. Mean and starndard deviations are allowed as scalar multiplications to the matrix.

  • 0
    My matrix is a feature matrix for linear regression. Each column of the matrix A represents a feature vector. So I need to normalize each feature vector by doing (actual value - mean)/SD. I want to do in matlab. In matlab Matrix operations are easier and fast to implement than using loops.2012-03-23

1 Answers 1

1

This should have been on SO.

Anyways,

for it=1:4 my_mean = mean(A(:,it)); my_sd = std(A(:,it)); B(:,it) = (A(:,it)-my_mean)/my_sd; end 

You may want to preallocate B for speed. B = zeros(5,4)