Hi, all, I want to define and store a large scale arrays, like ones(3^N,1000,N) and N can be 15. However, matlab says it is out of memory, because of the large scale.
I wonder is there any way to resolve it? I mean, to fulfill the purpose but satisfy the requirement of matlab? Actually ones(3^N, 1000,1) is still very large scale.
Thanks.

 채택된 답변

Image Analyst
Image Analyst 2013년 1월 6일

0 개 추천

Does it need to be double? Can it be single, uint8, or logical instead? Will it have any values other than 1 or small integers?

댓글 수: 5

C Zeng
C Zeng 2013년 1월 6일
Good idea! No, for ones(3^N,1000,N) array, only 0 1 or 2, that is uint8. However, for (3^N,1000,1) array, can be any positive fraction number.
I defines ones to give initial values.
OK, then does
yourArray = ones(rows, columns, N, 'uint8');
solve your memory problem?
C Zeng
C Zeng 2013년 1월 6일
Hi, sorry, still not working here. The problem is that 3^N can be very large, for example N can be 14, so 3^N*1000*N is very large, I think it exceeds the limit of Matlab. I created the array but it takes a lot of time, stay busy...
Image Analyst
Image Analyst 2013년 1월 6일
Are you sure that you need to whole matrix in memory at one time? Can't you work in "chunks"? Like work on a smaller cube of it at a time? Will you eventually access each and every one of those elements? Or can you use "sparse" matrices? Have you read the Mathworks guidance on this issue: Memory Usage
C Zeng
C Zeng 2013년 1월 6일
I may not need all matrix at a time and yes I can work in chunks. Let me double check the problem. Thank you for your suggestion!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Matt J
Matt J 2013년 1월 6일
편집: Matt J 2013년 1월 6일

1 개 추천

Are the entries mostly zeros? Could you use the SPARSE command?
If you need to work with n-dimensional sparse arrays, there is this:

댓글 수: 3

C Zeng
C Zeng 2013년 1월 6일
Thanks, will take a look. Unfortunately, entries may not be mostly zeros.
If they are mostly ones, you can express the array as
1 + sparse_array
and rewrite your computations in terms of that.
C Zeng
C Zeng 2013년 1월 6일
Yes, could be helpful, let me find it out. Thanks.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by