how to block diagonalize a 3D matrix

Respuestas (1)

Teja Muppirala
Teja Muppirala el 11 de En. de 2013
R = rand(4,2,3);
M = mat2cell(R,4,2,ones(1,size(R,3)));
M = blkdiag(M{:})

1 comentario

Timothy
Timothy el 26 de En. de 2016
Hmm. Make that third dimension a lot bigger.
R = rand(4,2,65341); tic M = mat2cell(R, 4,2,ones(1, size(R,3))); toc
Elapsed time is 6.065165 seconds.
I was hoping to use blkdiag to perform a [3x2] * [2 x 1] calculation a whole bunch of times, P = 65341 times. For looping through takes 2.5s. Setting up the block diagonal in this way is much slower. Is there a faster way?

Iniciar sesión para comentar.

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

Yue
el 11 de En. de 2013

Comentada:

el 26 de En. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by