Is there any way to normalize any matrix values to be between (-1) and (1)?

조회 수: 2 (최근 30일)
Hello,
Is there any way to normalize any matrix values to be exactly between (-1) and (1)? I attached the matrix.
regards,

채택된 답변

Image Analyst
Image Analyst 2019년 1월 12일
You can use mat2gray(), which normalizes data from 0-1 then just scale and subtract 1 to get into the range -1 to +1:
M = 2*mat2gray(M)-1;
A nice single-line solution.
  댓글 수: 4
Sarah A
Sarah A 2019년 1월 13일
No it is still between -1.0000 and 1.0000, is there any way to fix that ?
Walter Roberson
Walter Roberson 2019년 1월 13일
They would display as -1.0000 and 1.0000 especially with short format in effect, but if you take 1-max(M(:)) and min(M(:))+1 then you will see non-zero residues.

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

추가 답변 (2개)

madhan ravi
madhan ravi 2019년 1월 12일
편집: madhan ravi 2019년 1월 12일

Steven Lord
Steven Lord 2019년 1월 12일
Use the normalize function with the 'range' method if you're using release R2018a or later.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by