function [autovalor, autovetor,eixox,eixoy1,eixoy2]=metodo_das_potencias(A,b,n) t= input('Digite o valor máximo de iterações: '); e= input ('Digite a precisão desejada(na forma decimal): '); y{1}=b; z{2}=A*y{1}; p{2}=abs(max(abs(z{2}(:,1)))); y{2}=z{2}*(1/p{2}); z{3}=A*y{2}; l{2}=zeros(n,1); for c=1:n; l{2}(c,1)=z{3}(c,1)*(1/y{2}(c,1)); end for r=2:t; z{r+1}=A*y{r}; p{r+1}=abs(max(abs(z{r+1}(1:n,1)))); y{r+1}=z{r+1}*(1/p{r+1}); z{r+2}=A*y{r+1}; l{r+1}=zeros(n,1); for h=1:n; l{r+1}(h,1)=z{r+2}(h,1)*(1/y{r+1}(h,1)); end erro=zeros(n,1); for g=1:n; erro(g,1)=abs((l{r+1}(g,1)-l{r}(g,1))*(1/l{r+1}(g,1))); end if min(erro(:,1))<=e; [Q,w]=min(erro(:,1)); autovalor= l{r+1}(w,1); autovetor=y{r+1}; eixoy1(r)=l{r+1}(w,1); eixoy2(r)=max(eig(A)); eixox(r)=r; break end erro=zeros(n,1); for g=1:n; erro(g,1)=abs(l{r+1}(g,1)-l{r}(g,1))*(1/l{r}(g,1)); end [T,j]=min(erro(:,1)); autovalor=l{r+1}(j,1); autovetor=y{r+1}; eixoy1(r)=l{r+1}(j,1); eixoy2(r)=max(eig(A)); eixox(r)=r; end