Load Part of a Matrix or Cell array

Hey All,
I was wondering if the latest version of Matlab R2011a has any built in functionality, or if there's anything recent on the file exchange, that can load in only part of a vector, matrix or cell array stored in a ".mat" file.
For example if I have a file "output.mat" which contains a single variable "large_matrix" which is a (100x100) matrix is there a way I can load say the 10th element, large_matrix(10), without loading the entire matrix into memory?
The above is to just illustrate my question I know Matlab could easily load a 100x100 matrix into memory.
The most Matlab seems to offer is selectively loading variables e.g.
loaded_file = load('output','other_variable');
other_variable = loaded_file.other_variable;
But I'm hoping I'm wrong.
Any advice would be greatly appreciated, Thanks

답변 (3개)

Bjoern Hendrik Fock
Bjoern Hendrik Fock 2011년 6월 19일

1 개 추천

댓글 수: 3

Jan
Jan 2011년 6월 19일
+1. A nice summary of the frequency this feature is requested here.
Modern MAT-Files store the values of array in a compressed format. Accessing the values demands for a decompression of complete blocks. Therefore I assume, that it does not matter the efficiency if you cut out the wanted part inside the MAT reading function or in Matlab.
Walter Roberson
Walter Roberson 2011년 6월 19일
Jan, it could matter for memory use purposes. Suppose you wanted a small number of elements from a very large matrix. The decompression routine could read values and throw them away until it got to the correct place -- and if the values happened to be consecutive in the file, it wouldn't even have to hunt around and decompress other blocks.
There are, of course, efficiency issues such as if the user's request did not index the elements in monotonically increasing order and the list of requested elements was too large to sort in the available memory. None the less, there are cases where it would make sense for memory use and file efficiency to read selectively.
Dyuman Joshi
Dyuman Joshi 2023년 9월 14일
@Bjoern Hendrik Fock, the links you have attached don't seem to be working anymore.

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

Titus Edelhofer
Titus Edelhofer 2011년 6월 10일

0 개 추천

Hi,
unfortunately the answer is no (for R2011a). What I have done is to write a simple function that splits the variable into pieces when saving to a file, and read the pieces afterwards while processing the data...
Titus
Bjoern Hendrik Fock
Bjoern Hendrik Fock 2011년 9월 6일

0 개 추천

The feature seems to be added in Matlab R2011b by a new function called matfile. I will try this out the next days. MathWorks, this looks like an important improvement. Thank you for listening to your customers.
Bjoern

카테고리

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

질문:

2011년 6월 10일

댓글:

2023년 9월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by