There is more than one meaning of "normalize". Are you talking about the
standard deviation? Or do you mean something like:
N = norm(TheColumnVector);
if N == 0
error('Uh-oh, asked to normalize the null vector!');
end
NormalizedColumnVector = TheColumnVector ./ N;
So you have essentially a vector. You want the sum
of the vector to be 1. It has some other sum.
There are two simple ways to do this, given a
vector v,
v = rand(10,1);
sum(v)
ans =
6.2386
As you can see, v does not sum to 1.
You can either translate each element of v by an
amount,
v1 = v + (1 - sum(v))/length(v);
sum(v1)
ans =
1
or you can scale the vector.
v2 = v/sum(v);
sum(v2)
ans =
1
Either way will work. It depends on how you will
choose to define "normalize".
If you wish to do the nomialization on the entire
array after it has been generated, use the above
tricks in conjunction with bsxfun.
HTH,
John