matrix normalization in matlab
조회 수: 153 (최근 30일)
이전 댓글 표시
채택된 답변
Thorsten
2013년 1월 30일
To normalize a matrix such that all values fall in the range [0, 1] use
Anorm = (A - min2(A))/(max2(A) - min2(A));
댓글 수: 3
DGM
2022년 12월 11일
편집: DGM
2022년 12월 11일
There ./ is not needed here, since the denominator is a scalar.
That said, there is no function called min2() or max2(), nor can I find evidence that there were functions by those names which have since been removed. Maybe they used to be part of one of the toolboxes.
Alternatively, you could do:
Anorm = (A - min(A(:)))/(max(A(:)) - min(A(:)));
or you could do
Anorm = (A - min(A,[],'all'))/(max(A,[],'all') - min(A,[],'all'));
though the latter option wouldn't have worked circa 2013
추가 답변 (3개)
Matt J
2013년 1월 30일
You need to decide how you want to define the amplitude of the matrix first. Maybe you want this
normalized = A/norm(A);
or maybe this
normalized = A/max(abs(A(:)))
댓글 수: 3
Jan
2013년 1월 30일
Please, jenifer, we have asked you to define "normalization" exactly. It wastes time if we guess what you mean.
Jing
2013년 1월 30일
You can use 'normc' or 'normr' for normalization. 'c' or 'r' stands for columns or rows that you want to normalize.
댓글 수: 0
DGM
2022년 12월 11일
A = 1:6
B1 = normalize(A,'range') % default range is [0 1]
B2 = normalize(A,'range',[-1 2]) % but you can specify any range
B3 = normalize(A,'zscore','std') % zero-center and scale to have std=1
B4 = normalize(A,'norm',2) % normalize by vector p-norm (default p=2)
댓글 수: 2
Sinan Islam
2024년 8월 3일
The normalize function in matlab either works on columns or rows. We want a function that normalizes the matrix as a whole. We are not looking for normalizing features or observations. So the calculation must be made on global minimum and global maximum of the matrix. Thats why we flatten the matrix into one vector before doing any calculation.
DGM
2024년 8월 3일
As others have mentioned, "normalize" is a terribly vague word. If the goal is to rescale the entire array with respect to global statistics, then yes, reshaping the array is one way to do so.
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!