Two identical commands take different times to run?
Show older comments
I am running this function inside a bigger script:

K11 and K12 are just the same Matrix at start. I have two questions now:
- Why is line 11 taking much more than 9? It is the exact same command
- Why removing columns is much easier than removing rows?
Accepted Answer
More Answers (1)
Marta Salas
on 5 Mar 2014
0 votes
When you create a 2D array, you need to reference each element to its memory address. As a result, for a 2D array, you need to allocate MxN elements in memory (where M is the number of rows and N of columns). Since memory is a linear object, you need to choose how you organize these elements. You have two options “Row major order” or “Column major order”. Matlab choses the Column major order option.
Categories
Find more on Performance and Memory in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!