遗传算法的源代码下载,遗传算法的源代码下载

源代码在线查看: plsnipal.m

软件大小: 3748 K
上传用户: dounob
关键词: 算法 源代码
下载地址: 免注册下载 普通下载 VIP

相关代码

				function [p,q,w,t,u] = plsnipal(x,y)
				
				[my,ny] = size(y);
				if ny > 1
				  ssy = sum(y.^2);
				  [ymax,yi] = max(ssy);
				  u = y(:,yi);
				else
				  u = y(:,1);
				end
				conv = 1;
				told = x(:,1);
				count = 1.0;
				%  Specify the conversion tolerance
				while conv > 1e-10
				  count = count + 1;
				  w = (u'*x)';
				  w = (w'/norm(w'))';
				  t = x*w;
				  if ny == 1
				    q = 1;
				    break
				  end
				  q = (t'*y)';
				  q = (q'/norm(q'))';
				  u = y*q;
				  conv = norm(told - t);
				  told = t;
				  if count >= 50.0
				    disp('Algorithm Failed to Converge after 50 Iterations')
				    break;
				  end
				end
				p = (t'*x/(t'*t))';
				p_norm=norm(p);
				t = t*p_norm;
				w = w*p_norm;
				p = p/p_norm;
							

相关资源