How do I create an empty memmapfile object?
2 views (last 30 days)
Show older comments
I am trying to figure out how to create an empty memmapfile object. My situation is this: I have a loop where I'm finding the files associated with a project and creating a memory map of each one. That memory map, along with various other information is returned in a structure, which becomes part of a structure array. I've had a problem where occasionally one of the files fails in the processing, and then the whole system comes crashing to a halt because I'm trying to map dissimilar types of structures into the structure array (because the new one doesn't have a valid memmapfile).
What I want to do is to be able to define a default structure that will be returned in the event of a failed file load, but then I need to include a memmapfile object in the returned structure. I don't want to try to memmap a meaningless file, because I suspect that Matlab would really not like it if I mapped the same dummy file multiple times. So what would be the equivalent of:
dummy = memmapfile(0) ?
Is it to use the metaclass(memmapfile)? I wouldn't think so, but I really don't understand metaclasses at all.
Thanks, Dan
0 Comments
Accepted Answer
Walter Roberson
on 20 Feb 2012
MATLAB did not complain when I memmapfile('/dev/null') 1000 times. The MS Windows equivalent would be 'NUL:' as the file name.
Note that either of these would be completely empty, so you would encounter problems as soon as you attempted to use the data in the empty file. But that's a design issue, as you did not define what you wanted to have happen in such a case.
More Answers (0)
See Also
Categories
Find more on Data Import from MATLAB in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!