フィルターのクリア

How take Normalization for each column of 50x19 matrix?

6 ビュー (過去 30 日間)
Bajdar Nour
Bajdar Nour 2018 年 9 月 26 日
編集済み: Adam Danz 2018 年 9 月 26 日
I have the dataset like shown in the image below

回答 (1 件)

Adam Danz
Adam Danz 2018 年 9 月 26 日
編集済み: Adam Danz 2018 年 9 月 26 日
There are many interpretations and methods of normalization and the term is often used to describe standardization or rescaling so you'll need to specify what method you wish to use. Below I provide an example how to normalize columns of a matrix so that all values are between 0 and 1 according to the max and min within each column.
% fake data
data = randi(10, 6, 5);
% Subtract min of each column
datamin = data - min(data, [], 1);
% Scale to the max of each column
dataNorm = datamin ./ max(datamin, [], 1);
Now all values are of dataNorm are between 0 and 1 according to the max and min within each column. If this is what you meant by 'normalize', you can apply this to your data.
If you wanted to normalize via z-score, check out the normalize() function (from release 2018a). It also offers additional methods .
dataNorm = normalize(data, 1);
  4 件のコメント
Adam
Adam 2018 年 9 月 26 日
You may have to handle the case where a column is full of zeros though, if this is ever the case. You'll end up with Inf for your normalised values which may not be what you want (I assume you would want them to remain 0)
Adam Danz
Adam Danz 2018 年 9 月 26 日
編集済み: Adam Danz 2018 年 9 月 26 日
Good point. One way to avoid that is to divide by 1 if the column contains all 0s.
columnMax = max(data, [], 1);
columnMax(all(data==0,1)) = 1;
dataNorm = data ./ columnMax;

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

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by