how to normalize data by "mean & std" from all data?
3 次查看(过去 30 天)
显示 更早的评论
i have attached the data file.Is there are any shorter method to normalise?
% drill_bit: Drill bits to use
load dbhole.mat
drill_bit = 1:14;
% hole_idx: number of holes for each drill bit
hole_idx = zeros(1,length(drill_bit));
for i=1:length(drill_bit)
hole_idx(i) = length(whos(['d',num2str(drill_bit(i)),'h*']));
end
%%%%
sum1=0;
sum2=0;
sum3=0;
for i=1:length(drill_bit)
for k=1:hole_idx(i)
c=eval(sprintf('d%dh%d',drill_bit(i),k));
[m n]=size(c);
sum1= sum1+sum(c(:,1));
sum2=sum2+sum(c(:,2));
sum3=sum3+m;
end
end
mean1=sum1/sum3
mean2=sum2/sum3
sum0=0;
sum4_1=0;
sum4_2=0;
for i=1:length(drill_bit)
for k=1:hole_idx(i)
c=eval(sprintf('d%dh%d',drill_bit(i),k));
[m n]=size(c);
sum4_1= sum0+sum((c(:,1)-mean1).^2);
sum4_2= sum0+sum((c(:,2)-mean2).^2);
end
end
sigma1=sqrt(sum4_1/sum3)
sigma2=sqrt(sum4_2/sum3)
for i=1:length(drill_bit)
for k=1:hole_idx(i)
c1=eval(sprintf('d%dh%d',drill_bit(i),k));
A=(c1(:,1)-mean1)/sigma1;
B=(c1(:,2)-mean2)/sigma2;
A1{i}{k}=[num2cell(A) num2cell(B)];
% A1{i}{k}=num2cell(B);
clear A;
clear B;
end
end
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Random Number Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!