thank you very much!

By the way, how to get the diagonal matrix from vector diag(A)?

2013/12/13 Sven Schreiber <svetosch@gmx.net>

Am 13.12.2013 16:00, schrieb Qi Shi:

> Dear all,For example:

>

> how to transform a square matrix to a diagonal matrix using commands?

> for example, we have A={2,1;1,3}, how can I get a matrix B={2,0;0,3}?

>

diag(A)**ones(1,cols(A)) .* I(cols(A))

I'm not guaranteeing that this is the most elegant way, but in general

you should probably think about whether extracting diag(A) isn't enough

for your purposes, because it contains the same information.

-sven

_______________________________________________

Gretl-users mailing list

Gretl-users@lists.wfu.edu

http://lists.wfu.edu/mailman/listinfo/gretl-users