Borrar filtros
Borrar filtros

Different kind of normalization

2 visualizaciones (últimos 30 días)
Sam Da
Sam Da el 15 de Mzo. de 2011
Respondida: Steven Lord el 11 de Mayo de 2020
I have read in Matlab that normalization of a vector is u/norm(u).
However, I have a matrix (N x N)where the columns are different vectors. I want for each element of column vectors to do something like: (u(i) - mean(u))/std(u) without looping so that at the end of it each column vectors are bunch of standard normals.
Is there a standard way to do it in matlab or do I really have to code the loop.

Respuesta aceptada

Oleg Komarov
Oleg Komarov el 15 de Mzo. de 2011
% Create standard normal distributed samples with std = 100;
A = randn(100000,10)*100;
% Normalize
B = bsxfun(@rdivide,bsxfun(@minus,A,mean(A)), std(A));
% Check first column
hist(B(:,1),100)
Note that mean and std operate along rows, i.e. for a matrix they give a result for each column.
Oleg

Más respuestas (2)

Matt Tearle
Matt Tearle el 15 de Mzo. de 2011
If you have Statistics Toolbox, use uhat = zscore(u).

Steven Lord
Steven Lord el 11 de Mayo de 2020
Use the normalize function.

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by