필터 지우기
필터 지우기

Normalize/scale in range

조회 수: 3 (최근 30일)
Pete
Pete 2019년 10월 16일
답변: Kaashyap Pappu 2019년 10월 21일
hi all,
I would like to normalize values in a 18x17 matrix to have values between -1 and 1.
I would also like to be able to say that 0 = 76 mm, -1 = 71 mm, 1 = 81 mm for example instead of just using the min and max values in the array.
Any help would be greatly appreciated!
  댓글 수: 1
dpb
dpb 2019년 10월 16일
You can't do both unless the min/max are <= the chosen min/max.
NB: if you do choose the above three points the scaling between negative and positive results will be skewed by a significant amount -- double, in fact.
But, it's simply solving for the linear coefficients between the two...or you could use interp1

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

채택된 답변

Kaashyap Pappu
Kaashyap Pappu 2019년 10월 21일
The code below can help perform matrix normalization where you have to specify the appropriate -1, 0 and 1 values in variables "pointZero", "pointPositive" and "pointNegative". Any value lower than -1 is set to -1 and any value greater than one is set to 1.
Assuming "a" is your matrix,
a = (a - pointZero)/(pointPositive-pointNegative);
a(a<-1)=-1;
a(a>1)=1;
Note that the points raised by dpb are valid and could affect the properties of the values in the matrix.
Hope this helps!

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by