normalize a maatrix of 13 columns
Mostrar comentarios más antiguos
Hello
I have a matrix say A of 13 columns where each column represents a waveform. I am supposed to normalise each column of the matrix. I want to square each element of the matrix and carry out a summation of the elements in each column separately such that i have 13 values at the end. I want to take a squareroot of these 13 elements and then divide each column of the matrix A by the 13 elements. such that the first column of A is divided by the first element and so on. It would be very helpful if anyone can help me with this
Respuesta aceptada
Más respuestas (2)
Wayne King
el 13 de Ag. de 2012
Editada: Wayne King
el 13 de Ag. de 2012
You can just use
normc()
A = randn(1000,13);
B = normc(A);
If you happen to have the Neural Network Toolbox.
If you want to carry it out as you described.
A = randn(1000,13);
norm2 = sum(abs(A).^2,1);
norm2 = sqrt(norm2);
for nn = 1:size(A,2)
B(:,nn) = A(:,nn)./norm2(nn);
end
Matt Kindig
el 13 de Ag. de 2012
0 votos
Hi Kim,
Let's go through each step:
To square, use A^.2
To sum, use the sum() function. Read the documentation to learn about the dimension (DIM) argument to sum().
To square root, use the sqrt() function.
To normalize, you will need the element divide operator ./. You will also need the repmat() function.
Look at the documentation for these functions, and I'm sure you will be able to piece it together yourself.
Let us know if you have any further troubles, once you've looked over the documentation.
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!