Karhunen-Loève特征变换 模式识别课程实验

源代码在线查看: k_l_normalization.m

软件大小: 4 K
上传用户: fufuaihaitun
关键词: Karhunen-Lo 特征 变换 模式识别
下载地址: 免注册下载 普通下载 VIP

相关代码

				% M-file function, K_L_Normalization.m 
				% 对数据进行归一化处理
				function K_L_Normalization
				load iris.dat;
				x1 = iris(:,1);
				x2 = iris(:,2);
				x3 = iris(:,3);
				x4 = iris(:,4);
				mean1 = 0;
				mean2 = 0;
				mean3 = 0;
				mean4 = 0;
				v1 = 0;
				v2 = 0;
				v3 = 0;
				v4 = 0;
				for i =1:150
				    mean1 = mean1 + x1(i);
				    mean2 = mean2 + x2(i);
				    mean3 = mean3 + x3(i);
				    mean4 = mean4 + x4(i);    
				end
				mean1 = mean1 / 150;
				mean2 = mean2 / 150;
				mean3 = mean3 / 150;
				mean4 = mean4 / 150;
				for i =1:150
				    v1 = v1 + (x1(i) - mean1) ^ 2;
				    v2 = v2 + (x2(i) - mean2) ^ 2;
				    v3 = v3 + (x3(i) - mean3) ^ 2;
				    v4 = v4 + (x4(i) - mean4) ^ 2;
				end
				v1 = v1 / 149;
				v2 = v2 / 149;
				v3 = v3 / 149;
				v4 = v4 / 149;
				s1 = v1 ^ 0.5;
				s2 = v2 ^ 0.5;
				s3 = v3 ^ 0.5;
				s4 = v4 ^ 0.5;
				for i = 1 : 150
				    y1(i) = (x1(i) - mean1) / s1;
				    y2(i) = (x2(i) - mean2) / s2;
				    y3(i) = (x3(i) - mean3) / s3;
				    y4(i) = (x4(i) - mean4) / s4;   
				end
				Y(:,1) = y1;
				Y(:,2) = y2;
				Y(:,3) = y3;
				Y(:,4) = y4
				save X_Normal.dat Y -ascii;			

相关资源