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

2 ビュー (過去 30 日間)
Sarah A
Sarah A 2019 年 1 月 12 日
コメント済み: Walter Roberson 2019 年 1 月 13 日
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 日
  1 件のコメント
Sarah A
Sarah A 2019 年 1 月 12 日
Thank you for your answer. I tried all of them but it doesnt work.

サインインしてコメントする。


Steven Lord
Steven Lord 2019 年 1 月 12 日
Use the normalize function with the 'range' method if you're using release R2018a or later.

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by