How does matlab store matrix




















Select the China site in Chinese or English for best site performance. Other MathWorks country sites are not optimized for visits from your location. Toggle Main Navigation. Search Answers Clear Filters. Answers Support MathWorks. Search Support Clear Filters. Support Answers MathWorks. Search MathWorks. MathWorks Answers Support. Open Mobile Search. Trial software. You are now following this question You will see updates in your activity feed.

The matrix from the first file that the code loops through is the last cell in the cell array. I can't think of a good reason why this should be the case, other than maybe it is to do with the fact that I am looping through the files in reverse.

If I look at matrix, matrix 1 is a 6x2 matrix and matrix end is a 1x2 matrix, but in the cell array, the first cell is 1x2 and the last cell is 6x2. Why is this the case and what can I do about it? If I reverse the order of the kk iterations, it loops through matrix in the reverse order but store cellarray in the same way.

Rik on 7 Dec Cancel Copy to Clipboard. You are not showing your complete code, which makes it hard to come up with definitive answers. It looks like the kk counter determines which file you analyze and which cell position the results are stored in. That means that reversing the loop doesn't change the ordering of the cell array, just the order in which it is filled. If you want to store them in reverse order you will need something like this:.

Jan on 7 Dec JJH: This piece of code overwrites the elements of cellarray in each iteration of the outer loop. Is this intented? Accepted Answer. Stephen on 7 Dec Not at all. They are stored in the exact order that you specify using indexing, as I explained earlier:.

Index 1 is always index 1, no matter when you assign to it. Lets go through two simple examples step by step, first in descending order, like your code:. The loop iterations are:. Reload the page to see its updated state. Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:. Select the China site in Chinese or English for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Toggle Main Navigation. Search Answers Clear Filters. Answers Support MathWorks. Search Support Clear Filters. Support Answers MathWorks. Search MathWorks. MathWorks Answers Support. Open Mobile Search.



0コメント

  • 1000 / 1000