开发者

normalize mat file in matlab

开发者 https://www.devze.com 2023-04-12 19:50 出处:网络
开发者_开发技巧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) I assume that you want to normalize each column.
开发者_开发技巧

I have a mat file with a structure that looks like this:

normalize mat file in matlab

How do I normalize the data and save it as a .dat file (ascii)


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.


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
0

精彩评论

暂无评论...
验证码 换一张
取 消