Diagonal Matrices Generation

Good day all, pls, can someone assist, i want to generate a diagonal matrices from a random matrix just similar to how generation of particles is done in particle swarm optimization (PSO) as; Let say N=10; iterations=100; P=rand(N,2,1) At the first, i want generate 10 diagonal matrices from the row of P of size 2x2 (i.e one diagonal matrix from each row). as for iter=1:iterations for i=1:N K(i,1,1,)=diag(P(i,1,1)); i.e to generate a 10 diagonal matrices of 2x2 and store it as previous then the current,
for j=2:iterations-1 for i=1:N K(i,1,j)=diag(P(i,1,j)); i.e to generate diagonal matrices of 2x2 up to j and these diagonal matrices of 2x2 to be the current. Thanks
Best regards,

Risposte (0)

Richiesto:

il 28 Mar 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by