Hi there,
How would you normalize a column of data in matlab between 0 and 1 using the formula, z = (x-mean)/standard deviation. Is there a built in function to do this?
Many thanks
John

댓글 수: 1

Merhan Ahmed
Merhan Ahmed 2017년 1월 25일
zscore function could be used as Z = zscore(X)

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

 채택된 답변

Junaid
Junaid 2011년 12월 21일

4 개 추천

Dear John,
Lets say you have matrix D and you want to normalize each value of Column to unit length (between 0-1). One possible way is :
D = bsxfun(@rdivide,D,sum(D));
each column will be unit normalized. If you take the sum of each column it will be one.
sum(D)
Do let me know if I understand you correct.

댓글 수: 1

bym
bym 2011년 12월 23일
zscore from the statistics toolbox does (x-mean)/standard deviation

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

추가 답변 (3개)

Jurgen
Jurgen 2012년 11월 18일

0 개 추천

Dividing by the maximum does not correct for offset. So only ranges 0-X go to 0-1. If his column has a negative or nonzero minimum it won't normalize to 0-1.
While the formula for correcting this is simple, mat2gray will normalize to 0-1 for you:
for i = 1:ncol
D(:,i) = mat2gray(D(:,i))
end
You have to decide if you need to normalize before or after your calculation.
VoyageR
VoyageR 2016년 11월 3일

0 개 추천

Also don't forget to set your data as double otherwise you will only have 1 or 0 in your normalized vector ; )
double(vectorOfIntergers)
marwa el-hossary
marwa el-hossary 2018년 5월 7일

0 개 추천

plz, how can I normalize data of matrix 1x256000 between -0.5 and +0.5 by matlab code

댓글 수: 2

Steven Lord
Steven Lord 2018년 5월 7일
Use the normalize function with the 'range' method and a methodtype input.
Nikhil Jahagirdar
Nikhil Jahagirdar 2019년 4월 10일
Does it support MAtlab R2016b?

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

태그

질문:

2011년 12월 21일

댓글:

2019년 4월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by