Pregunta

For example: I have first vektor x1:

 x1=[4.8809    0.0034
 4.3352    0.0080
 3.3940    0.0119]

and second vector x2:

 x2=[2.1531    0.0147
 0.7522    0.0162
-0.6510    0.0162]

This steps I would like to make as a loop:

1) first row of matrix Z

 z1=x1(1,:)

2) second row of matrix Z

 z2=x2(1,:)

3) matrix Z

 Z=[z1;z2]

4) eigenvalues ​​of matrix Z

 e=eig(Z)

5) make a vector from eigenvalues v

 v= [e(1) , e(2) , ...]

and the same steps for z1=x1(2,:) and so on... And result is vector v with eigenvalues of matrix Z.

I don't know how to make it, thank you for your answers, I hope this is clear ;)

¿Fue útil?

Solución

You are really close to the solution.

%preallocate v with a zero-array
v=zeros(size(x1))';
for idx=1:size(x1,1)
  %replace the 1 with an index
  z1=x1(idx,:);
  z2=x2(idx,:);
  Z=[z1;z2];
  e=eig(Z);
  %select the right column
  v(:,idx)=e;
end
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top