Slowing down when doing calculations with catenated matrix
Afficher commentaires plus anciens
I'm trying to speed up my code. The original code is here:

I think the "kron" function is repeatedly calculated within the loop "i=1:3", so I moved the kron function outside it:

And it turned out to be slower, even when the use of "kron" is reduced by three times. The reason I found out later is catenating the three copies of "temp" into the third dimension, and I tried the following code:

And this time it's much faster. So my question is why working with catenated matrix is very slow, when the calculation is the same. What in general is to be avoided? Thanks!
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!