normalization , colums, rows

조회 수: 2 (최근 30일)
Dhurgham Al-karawi
Dhurgham Al-karawi 2018년 5월 26일
편집: Dhurgham Al-karawi 2018년 5월 26일
Hi everyone,
May I know which way correct to do normalization for a matrix by colums or rows?
Thanks.
  댓글 수: 2
Ameer Hamza
Ameer Hamza 2018년 5월 26일
The correct way depends on what you are trying to do, how are you normalizing etc. You need to specify what is your purpose for normalizing the matrix.
Dhurgham Al-karawi
Dhurgham Al-karawi 2018년 5월 26일
Thanks for your reply. I wanna do classification using SVM. The dimension of the matrix is 242* 256.

댓글을 달려면 로그인하십시오.

채택된 답변

Jan
Jan 2018년 5월 26일
편집: Jan 2018년 5월 26일
x = rand(242, 256),
xNRow = x ./ sum(x, 2); % Auto-expanding, Matlab >= R2016b
xNCol = x ./ sum(x, 1);
For older Matlab versions:
xNRow = bsxfun(@rdivide, x, sum(x, 2));
xNCol = bsxfun(@rdivide, x, sum(x, 1));
Now the rows or columns are normalized, such the the sum is 1.0. But perhaps you want the norm to be 1.0?
xNRow = x ./ vecnorm(x, 2); % Auto-expanding, vecnorm needs >= R2017b
xNCol = x ./ vecnorm(x, 1);
Or with older Matlab versions:
xNRow = x ./ sqrt(sum(x .* x), 2)); % Auto-expanding, >= R2016b
xNCol = x ./ sqrt(sum(x .* x), 1));
or again with bsxfun.
There are more methods for a "normalization": Set the mean to zero, and/or the std to 1 or such that the maximum peak height is 1.0. So you have to find out, what you need mathematically. Then the implementation in Matlab is easy.
  댓글 수: 2
Dhurgham Al-karawi
Dhurgham Al-karawi 2018년 5월 26일
Thanks for kind information. It seems that the normaliztion is done for both colums or rows. Is it okey to do normaliztion for colums only.Because when i do it for rows only the performace is getting low but with colums it is very high. That's why am asking which one correct rwos or colums. Thanks again
Dhurgham Al-karawi
Dhurgham Al-karawi 2018년 5월 26일
편집: Dhurgham Al-karawi 2018년 5월 26일
I have used the following formula to do normalaztion
minData=min(min(Class1_feature))
maxData=max(max(Class1_feature));
Class1_feature=((Class1_feature-minData)./(maxData));

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by