How to normalize values in a matrix to be between 0 and 1?
이전 댓글 표시
I have a matrix Ypred that contain negative values and I want to normalize this matrix between 0 and 1
Ypred=[-0.9630 -1.0107 -1.0774
-1.2075 -1.4164 -1.2135
-1.0237 -1.0082 -1.0714
-1.0191 -1.3686 -1.2105];
I'm new in matlab, please help me, there is a matlab function or toolbox that can do this? thanks
댓글 수: 2
James Tursa
2015년 4월 8일
편집: James Tursa
2015년 4월 8일
What do you mean by "normalize"? Divide by the max value in the matrix and make all values positive? Do this by columns or rows? Divide by norm of columns or rows? Or what?
Sahar abdalah
2015년 4월 8일
채택된 답변
추가 답변 (3개)
James Tursa
2015년 4월 8일
NormRows = sqrt(sum(Ypred.*Ypred,2));
Ynorm = bsxfun(@rdivide,abs(Ypred),NormRows);
댓글 수: 3
Tubi
2018년 3월 10일
If I want to use this code for my work, any way should I use to cite/reference?
John D'Errico
2018년 3월 10일
편집: John D'Errico
2018년 3월 10일
Why would you need a citation? If you truly want a citation, just cite MATLAB itself, or perhaps the doc page for bsxfun, but it seems a bit silly to need a citation for a simple code fragment.
Tubi
2018년 3월 22일
Many Thanks John, I believe you are right in your suggestion since they are mostly common MATLAB commands and functions.
Sahar abdalah
2015년 4월 9일
댓글 수: 2
James Tursa
2015년 4월 9일
Use whichever is appropriate for your problem. Jos and I are both trying to interpret what you want, but without any background about the problem you are solving it is a bit of a guessing game at our end.
Sahar abdalah
2015년 4월 9일
c4ndc
2017년 8월 12일
0 개 추천
Hello, What is the name of this norm in the accepted answer? (Euclidean, Frobenius etc.)
댓글 수: 1
Jan
2017년 8월 12일
Please post comments to answers in the section for the comments. You message is not an answer.
The accepted answer does not contain a norm at all, but a "normalization". A matrix norm would reply a scalar, the normalization replies a matrix with the same size, but with shifted and scaled values.
카테고리
도움말 센터 및 File Exchange에서 Random Number Generation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!