normalize mat file in matlab

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 11:04:38

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!