Boolean Variables in Matlab
이전 댓글 표시
Hi, I want to have a large 2D nxn array in which I want to store 0 or 1 at each cell, so basically a bit would do for one cell of a matrix. And the array I want to create have high dimensions so space is a constraint. So is there any thing which can provide bit access so that the whole program may run using decent memory.
Thanks
댓글 수: 2
Walter Roberson
2013년 7월 1일
What operations do you need to perform on the array?
Akashdeep Saluja
2013년 7월 1일
답변 (1개)
Jonathan Sullivan
2013년 7월 1일
편집: Jonathan Sullivan
2013년 7월 1일
No. MATLAB does not have any native bit sized data types. The best you are going to be able to do is to (without creating your own class) is use logicals, which esentially are bytes (8 bits). Also, do not use cell array if you are concerned about space. Each element in a cell array has a non-neglegable amount of overhead to define the size, shape, and type of the data it stores.
help logical
doc logical
댓글 수: 3
Jonathan Sullivan
2013년 7월 1일
The other thing to look at is a sparse array. Depending on how dense your data set is, a sparse array could help you out considerably.
Akashdeep Saluja
2013년 7월 1일
James Tursa
2013년 7월 1일
편집: James Tursa
2013년 7월 1일
FYI, doing anything that changes the non-zero locations of a sparse matrix will in all likelihood lead to copying the entire underlying dataset to new memory. I.e., each and every operation you do that changes the non-zero locations will cause an entire dataset copy to take place. This will drag your performance considerably depending on the sizes involved.
카테고리
도움말 센터 및 File Exchange에서 Data Type Identification에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!