matrix normalization in matlab
119 次查看(过去 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)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!