问题
I have a mat file with a structure that looks like this:
How do I normalize the data and save it as a .dat file (ascii)
回答1:
I assume that you want to normalize each column.
There are two ways you can normalize:
(1) Set minimum to 0 and maximum to 1
dataset = bsxfun(@minus,dataset,min(dataset));
dataset = bsxfun(@rdivide,dataset,max(dataset));
(2) Set average to zero, standard deviation to 1 (if you don't have the Statistics Toolbox, use mean and std to subtract and divide, respectively, as above).
dataset = zscore(dataset);
EDIT
Why anyone ever use option 2 to normalize?
When you calculate the difference (dissimilarity) between different data points, you may want to weigh the different dimensions equally. Since dimensions with large variance will dominate the dissimilarity measure, you normalize the variance to one.
回答2:
Your normalization:
dataset = dataset-ones(size(dataset,1),1)*min(dataset) % subtract min
dataset = dataset ./ (ones(size(dataset,1),1)*max(dataset)+eps) % divide by max
来源:https://stackoverflow.com/questions/7729880/normalize-mat-file-in-matlab