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,
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Particle Swarm 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!