필터 지우기
필터 지우기

How to normalize negative values in column vector

조회 수: 3 (최근 30일)
Raady
Raady 2016년 8월 17일
댓글: Image Analyst 2016년 8월 17일
Matlab 2015a
Hello, I have a column vector of 180 elements, with min(vector) = -1.6010 and max(vector) = 0.3894. when I apply normc(vector), and find min(vector) = -0.1318 and max(vetor) = 0.0321 for which I except the values to be in between 0 and 1. How to resolve this ??
When I am having positive values I do for ranging between 0 to 1
normalized_vector = (vector -min(vector)).max(vector);
but its not working with the negative values.

채택된 답변

Image Analyst
Image Analyst 2016년 8월 17일
If you have the Image Processing Toolbox, you can simply use mat2gray:
normalizedVector = mat2gray(vector);
Now normalizedVector will go from 0 to 1. Otherwise, if you are so unfortunate as to not have one of the best toolboxes out there, just scale as you normally would:
normalizedVector = (vector - min(vector)) / (max(vector)-min(vector));
  댓글 수: 2
Raady
Raady 2016년 8월 17일
편집: Raady 2016년 8월 17일
Speaking about a vector having all positive values alone. I need to apply this feature to one of the classifier. Which way normalizing data is better using matlab inbuilt function 'normc(vector)' or normalizing to range 0 to 1 by using 'mat2gray'? when I apply these functions output of both are completely different. Please suggest.
Please comment if I need to open as another thread !
Image Analyst
Image Analyst 2016년 8월 17일
I don't know. normc() is not a built in function for any of the toolboxes that I have so I don't know what it does.
Both of the statements I give you will give the same results. Both map the min to 0 and the max to 1 and it's linearly scaled in between. I think mat2gray() is the simplest, but you can use whichever one you want.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by