matlab归一化问题

发布于 2024-11-29 15:49:41 字数 698 浏览 4 评论 0原文

我有84组数据,第一组数据通过下面的代码进行归一化...归一化方程是(((N-min)*2)/(max-min))-1)...

%read 1st set of data
N = xlsread('output1.xls','data');    

%normalize the 27 columns
N = bsxfun(@minus,N,min(N,[],1));
N = bsxfun(@times,N,2./max(N,[],1));
N = N - 1;
xlswrite('output1.xls',N,'normdata');

现在,每个数据集有 27 列。从第一个数据集的原始数据中,找出每列的最大值和最小值。因此,每列有 27 个最大值和 27 个最小值...然后通过为每列使用这 27 个最大值和 27 个最小值,标准化第一组数据和第二到第 84 数据集...

但是,下面的代码来自 b3 答案,与上面的代码结果不同。

N = xlsread('output1.xls', 'data');
minN1 = min(N);
maxN1 = max(N);
N = bsxfun(@minus, N, minN1);
N = bsxfun(@times, N, 2./maxN1);
N = N - 1;
xlswrite('output1.xls',N,'normdata');

我可以知道代码有什么问题吗?

I have 84 sets of data, the 1st set of data was normalized by the code below...The normalize equation is (((N-min)*2)/(max-min))-1)...

%read 1st set of data
N = xlsread('output1.xls','data');    

%normalize the 27 columns
N = bsxfun(@minus,N,min(N,[],1));
N = bsxfun(@times,N,2./max(N,[],1));
N = N - 1;
xlswrite('output1.xls',N,'normdata');

Now, every dataset have 27 columns. From original data of 1st dataset, find out the max and min for each column..so, we have 27 max values and 27 min values for each column...then by using these 27 max values and 27 min values for each column, to normalize the 1st set data and 2nd to 84th dataset...

The code below from b3 answer, however, which is different result from the above code.

N = xlsread('output1.xls', 'data');
minN1 = min(N);
maxN1 = max(N);
N = bsxfun(@minus, N, minN1);
N = bsxfun(@times, N, 2./maxN1);
N = N - 1;
xlswrite('output1.xls',N,'normdata');

May i know what's wrong with the code?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小…楫夜泊 2024-12-06 15:49:41

在您的示例中,第一个数据集位于名为 output1.xls 的文件中,因此我假设所有输入文件的格式为 output#.xls。存储第一个文件的标准化参数,然后循环遍历其余文件,重复标准化计算。

N = xlsread('output1.xls', 'data');
minN1 = min(N);
maxN1 = max(N);
N = normalize(N, minN1, maxN1);
xlswrite('output1.xls', N, 'normdata');
for ii = 2:84
    filename = sprintf('output%u.xls', ii);
    N = xlsread(filename, 'data');
    N = normalize(N, minN1, maxN1);
    xlswrite(filename, N, 'normdata');
end

function N = normalize(N, minN1, maxN1)
    N = bsxfun(@times, N 2./(maxN1-minN1));
    N = N - 1;
end

In your example, the first data set is in a file called output1.xls so I'm assuming all your input files are of the form output#.xls. Store the normalization parameters for the first file and then loop over the remaining files repeating the normalization calculation.

N = xlsread('output1.xls', 'data');
minN1 = min(N);
maxN1 = max(N);
N = normalize(N, minN1, maxN1);
xlswrite('output1.xls', N, 'normdata');
for ii = 2:84
    filename = sprintf('output%u.xls', ii);
    N = xlsread(filename, 'data');
    N = normalize(N, minN1, maxN1);
    xlswrite(filename, N, 'normdata');
end

function N = normalize(N, minN1, maxN1)
    N = bsxfun(@times, N 2./(maxN1-minN1));
    N = N - 1;
end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文