[問題] 如何用粒子群求特徵向量已回收

看板MATLAB作者 (family)時間16年前 (2010/04/07 19:00), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
請問一下版上的各位高手, 小妹我在做粒子群的問題, 我遇到了一個問題! 我知道求特徵值與特徵向量可用: [V,D]=eig(A,B) 來求出特徵值與特徵向量! 但是我想要利用粒子群來解特徵向量, 目前我只會用粒子群解出特徵值, 我不知道特徵向量該如何下手! 以下是我解特徵值的程式:(其中也有參考版上各位大大的文章) clc clear A=[-2.7178 -2.0947 0.2311 508576 3.7818; -3.5536 -1.1199 0.2404 6.0543 3.8102; -2.2458 -2.8730 0.6181 6.0015 4.7950; -1.2359 1.3860 1.2419 -1.1440 -1.0859; -1.6108 0.4044 -0.3059 2.2151 1.2326]; %--------The settings of PSO parameter------- pop_n=50; Dimen=2; Xmin=-10*ones(1,Dimen); Xmax=10*ones(1,Dimen); iter=0; itermax=300; C1=2; C2=2; Wi=0.9; Wf=0.4; %--------Particle Swarm initialization------- X=zeros(pop_n,Dimen); pbest=zeros(1,pop_n); V=zeros(pop_n,Dimen); Fit=zeros(1,pop_n); Vmax=0.05*Xmax; for i=1:pop_n X(i,:)=(Xmax-Xmin).*rand(1,Dimen)+Xmin; c(i)=X(i,1)+X(i,2)*j; e=(A-c(i)*eye(5)); E=det(e)/((c(i)-(0.5353+0.7365*j))*(c(i)-(0.5353-0.7365*j))); pbest(i)=abs(E); V(i,:)=2*Vmax.*rand(1,Dimen)+Vmax; V(i,:)=2*Vmax.*rand(1,Dimen)+Vmax; end Pbest=X; [gbest,g]=min(pbest); Gbest=X(g,:); while(1) W=Wi+(Wf-Wi)*iter/itermax; for i=1:pop_n V(i,:)=W*V(i,:)+C1*rand(1,Dimen).*(Pbest(i,:)-X(i,:))... +C2*rand(1,Dimen).*(Gbest-X(i,:)); V(i,:)=(abs(V(i,:))>Vmax).*sign(V(i,:)).*Vmax... +(abs(V(i,:))<=Vmax).*V(i,:); X(i,:)=V(i,:)+X(i,:); X(i,:)=(X(i,:)>Xmax).*Xmax+(X(i,:)<=Xmax).*X(i,:); X(i,:)=(X(i,:)<Xmin).*Xmin+(X(i,:)>=Xmin).*X(i,:); c(i)=X(i,1)+X(i,2)*j; e=(A-c(i)*eye(5)); E=det(e)/((c(i)-(0.5353+0.7365*j))*(c(i)-(0.5353-0.7365*j))); Fit(i)=abs(E); if Fit(i)<pbest(i) pbest(i)=Fit(i); Pbest(i,:)=X(i,:); end end [New_gbest,New_g]=min(pbest); if New_gbest<gbest gbest=New_gbest; g=New_g; Gbest=X(g,:); end if iter>=itermax,break,end iter=iter+1; end disp(Gbest) 請問我特徵向量該如何下手? 麻煩各位大大了! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.120.109.24 ※ 編輯: family1986 來自: 140.120.109.24 (04/07 19:01)
文章代碼(AID): #1Bl6NPoH (MATLAB)
文章代碼(AID): #1Bl6NPoH (MATLAB)