normalize a maatrix of 13 columns
이전 댓글 표시
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
채택된 답변
추가 답변 (2개)
Wayne King
2012년 8월 13일
편집: Wayne King
2012년 8월 13일
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
2012년 8월 13일
0 개 추천
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.
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!