Is possible put a vector as a diagonal of matrix ?

Risposte (3)

Andrei Bobrov
Andrei Bobrov il 13 Feb 2014
Modificato: Andrei Bobrov il 13 Feb 2014
blkdiag(A,A,A)
or
A = [1 2];
n = 4;
a1 = repmat({A},n,1);
out = blkdiag(a1{:});
n=3;
a=repmat([1 2 zeros(1,2*n-2)],n,1);
b=arrayfun(@(x) circshift(a(x,:),[0 2*(x-1)]),(1:n)','un',0);
out=cell2mat(b)
A = [1 2] ;
n = 3 ;
B = kron(eye(n),A)

2 Commenti

Thats works just fine !! thanks
You're welcome. If you're satisfied you can accept the answer so others know as well.

Accedi per commentare.

Categorie

Richiesto:

il 13 Feb 2014

Commentato:

il 13 Feb 2014

Community Treasure Hunt

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

Start Hunting!

Translated by