Search code examples
matlabmemory-mapped-files

call Matlab's memmapfile with subsasgn


I have a large writable Matlab's memmapfile object that I want to access and modify.

Access

If I try:

mmap.Data.bit(1)

or

subsref(mmap.Data.bit, substruct('()', {1}))

I get the same value (0).

Modify

If I try:

mmap.Data.bit(1) = 1

I can assign this value very quickly, but if I try:

[~] = subsasgn(mmap.Data, substruct('.', 'bit', '()', {1}))

Matlab stops responding and never ends the line.

What is the problem with subsasgn and mmap?


Solution

  • What Matlab was actually trying to do is to load the whole content of the file.

    The correct line is:

     [~] = subsasgn(mmap, substruct('.', 'Data', '.', 'bit', '()', {1}))