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!