Question regarding how matrices are stored in memory
이전 댓글 표시
I'm trying to get a simulation running which requires a big matrix (
N~400), so being smart with memory is important.
The issue: Sparing the details of what I am doing I generate this matrix, call it S, and then multiply it by a number Δ. When I do this, I get an error that matlab doesn't support array sizes this big.
Now if I decide to measure my energy scale in respect to Δ, I do not need to multiply S by it, and this matrix fits in memory. However, the number of elements in my matrix is the same... This got me thinking: how are numbers stored in matrices here?
My thoughts: I always thought that memory is allocated when you define a matrix: we have a floating point number with 64 bits of memory for each element in our matrix.
This situation makes it seem like an
matrix with all zeros takes less memory than one with all 2.718281828459045's. Of course the latter requires more to describe than the former; I just thought things were preallocated.
My questions: Does matlab only keep track of the decimal and significant figures and the fewer of these the smaller? Or does it cast variables to a smaller size or something automatically? Or is it the case that what I said in the previous paragraph is right regarding allocating a fixed amount of memory at the start? Or something else...
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
