renaming large variables programmatically
이전 댓글 표시
Hello,
I would like to rename a variable programmatically, and without copying it.
I work with large audio files, so "y=x; clear x" may blow up the memory.
I would like to do this within a program instead of having to click in the Workspace.
Saving it to a binary file, clearing the variable, then reading and deleting the binary file is a bit of a hack, so I'd rather do something more elegant.
Thanx in advance!
채택된 답변
추가 답변 (2개)
Sean de Wolski
2011년 9월 20일
0 개 추천
You could try doing it in chunks though there's no guarantee that'll be faster. You could also convert to single precision if necessary.
Loading the variable and immediately assigning it a name on load is probably your best bet.
Matlabber 1.0
2016년 11월 4일
Dear all, to pick up on exact the same topic abouth "why renaming??": i have a few large chunks of image data, each set has a different amount of images. Imagine a the biggest set of 2000 images of 1200x2000 pixel, resulting in ~35gb with double representation (required).
since for processing these data i cannot load it into memory at once (16gb machine), i slice it up in ~4gb chunks and save them to disk. here some pseudocode:
for i=1:number_of_4gb_chunks_required % iterate the 4gb chunks
Chunk=zeros(SizeOf4gbChunk); % initialize 4gb chunk
for j=[ImageNumbersThatGoToChunk_i] % iterate images
ImData=ReadInFileNr_i();
PutImDataintoChunk()
end
renameChunkToChunk_i
save(Chunk_i.mat,Chunk_i) % save the current block as Chunk_i.mat
end
later i want to load any of those block programmatically and apply repetitive image processing on them. How do you recommend me to do this? My current solution involves eval(). i would like to get rid of it but i don't know how. can you help me? thanks!
댓글 수: 1
Steven Lord
2016년 11월 4일
카테고리
도움말 센터 및 File Exchange에서 Large Files and Big Data에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!