필터 지우기
필터 지우기

Normalization of an array of double

조회 수: 6 (최근 30일)
Guido Pastore
Guido Pastore 2019년 3월 3일
편집: Stephan 2019년 3월 3일
How do I normalize an array of double from 0 to 1 ??

채택된 답변

Stephan
Stephan 2019년 3월 3일
편집: Stephan 2019년 3월 3일
Hi,
in R2018b use:
A = A ./ max(A,[],'all')
If you need performance use the good old classic way (see comment on the other answer):
A = A ./ max(A(:))
Best regards
Stephan
  댓글 수: 1
madhan ravi
madhan ravi 2019년 3월 3일
max(A,[],'all') % since 2018b
max(A(:)) % prior to 2018b

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

추가 답변 (1개)

Sheng Chen
Sheng Chen 2019년 3월 3일
Try this
v = [1.3, 5.6, 2.2, 1.0, 3.32];
N = normalize(v,'range');
'range' means scale range of data to [0,1].
Also, please refer to Normalize data
  댓글 수: 1
Stephan
Stephan 2019년 3월 3일
For bigger data sets i would prefer the classic way before 2018b changes came:
A = randi(100,10,10,10);
res_1a = @(A) A./max(A,[],'all');
res_1b = @(A) A./max(A(:));
res_2 = @(A) normalize(A,'range');
tic
r1a = res_1a(A);
toc
tic
r1b = res_1b(A);
toc
tic
r2 = res_2(A);
toc
results in:
Elapsed time is 0.000805 seconds.
Elapsed time is 0.000427 seconds.
Elapsed time is 0.057486 seconds.

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by