How to normalize a matrix or array?

13 ビュー (過去 30 日間)
M Mirza
M Mirza 2023 年 2 月 20 日
回答済み: Bhavana Ravirala 2023 年 2 月 20 日
I want to normalize the following array/matrix in such a way that
1) Replace each Row element with average value of that Row.
2) Normalize the matrix with respect to the row with maximum average.
A1 A2 A3 A4 . . . An
B1 B2 B3 B4 . . . Bn
C1 C2 C3 C4 . . .Cn
D1 D2 D3 D4 D5. . . Dn
I shall be really grateful.
  2 件のコメント
Askic V
Askic V 2023 年 2 月 20 日
I suggest you to start by reading the Matlab documentation.
It would be good to post one test example. How matrix look like in the begining of the process and how outcome looks like.
Dyuman Joshi
Dyuman Joshi 2023 年 2 月 20 日
It's not clear how you want to replace the values.
Let's say this is the input
y = reshape(1:20,4,5)
y = 4×5
1 5 9 13 17 2 6 10 14 18 3 7 11 15 19 4 8 12 16 20
What should be the output(s)?

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

回答 (1 件)

Bhavana Ravirala
Bhavana Ravirala 2023 年 2 月 20 日
Hi Mirza,
I understand that you want to replace each row with the average of all the elements in that row.
A = [0 1 1; 2 3 2; 1 3 2; 4 2 2]
M = mean(A,2) % gives a column vector with the average of all the elements in each row.
For getting the maximum value you can use the ‘max’ function.
Please refer to the below documentation for more information.
Hope this helps!!

カテゴリ

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