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!