フィルターのクリア

How to prepare normalized feature matrix in MATLAB ?

1 回表示 (過去 30 日間)
charu shree
charu shree 2023 年 3 月 17 日
コメント済み: charu shree 2023 年 3 月 17 日
Hello all, I am having a feature matrix say of dimension 500 by 4. I want to normalize this feature matrix and obtain normalized feature matrix such that element of is obtained as ----(1)
where indicates element of feature matrix .
My query is how can we obtain normalized feature matrix from equation (1).
Any help in this regard will be highly appreciated.
  1 件のコメント
charu shree
charu shree 2023 年 3 月 17 日
編集済み: charu shree 2023 年 3 月 17 日
I tried with 'for loop' and getting the proper answer. Here are my efforts:
for i = 1:500
for j = 1:4
p1 = min(D(i,:));
p2 = max(D(i,:));
d_ij = D(i,j);
deno = p2-p1;
numer = d_ij-p1;
P(i,j) = numer/deno;
end
end
Is there any other way so that I can avoid 'for loop' ?

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

採用された回答

Dyuman Joshi
Dyuman Joshi 2023 年 3 月 17 日
%Random data
D = rand(500,4);
%minimum of each row
minval=min(D,[],2);
%maximum of each row
maxval=max(D,[],2);
%Vector approach
P1=(D-minval)./(maxval-minval);
P2=zeros(size(D));
for i = 1:500
for j = 1:4
p1 = min(D(i,:));
p2 = max(D(i,:));
d_ij = D(i,j);
deno = p2-p1;
numer = d_ij-p1;
P2(i,j) = numer/deno;
end
end
%Checking if the outputs are equal or not
isequal(P1,P2)
ans = logical
1
  1 件のコメント
charu shree
charu shree 2023 年 3 月 17 日
Thank you very much sir....

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by