Creating a memory mapped file

12 Ansichten (letzte 30 Tage)
Ken
Ken am 31 Aug. 2016
Kommentiert: Ken am 1 Sep. 2016
I am trying to create a new memory-mapped 'big data' file by using sequential writes of structured binary data, where I write a vector of values for each variable separately. First, can I start with an empty file that I have opened for write? I cannot seem to write an array into mapped location unless data already exists at that location. See below
%%define the memory map for the output binary file
OutFile = 'testOutFile';
fid = fopen('test.lls','w');
mmLLS = memmapfile('test.lls',...
'Format',{ ...
'single' 1 'lat'; ...
'single' 1 'lon'},...
'Repeat',1,'Writable',true);
Lat = single(32.3);
Lon = single(-110.2);
mmLLS.Data.lat = Lat;
Error using memmapfile/subsasgn (line 732)
A subscripting operation on the Data field attempted to create a
comma-separated list. The memmapfile class does not support the use
of comma-separated lists when subscripting.
  1 Kommentar
per isakson
per isakson am 31 Aug. 2016
Bearbeitet: per isakson am 31 Aug. 2016
"First, can I start with an empty file that I have opened for write?" &nbsp The short answer is NO!
Doc says: "Memory-mapping is a mechanism that maps a portion of a [existing] file, or an entire [existing] file, on disk to a range of addresses within an application's address space."

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 1 Sep. 2016
"memmapfile does not expand or append to a mapped file. Use instead standard file I/O functions like fopen and fwrite."
  1 Kommentar
Ken
Ken am 1 Sep. 2016
Thank you for this clarification, although it is disappointing, when combined with the fact that Matlab cannot write sequences of binary complex structures.
It would be helpful if this fact were stated clearly/explicitly when describing the capability to write to a memory mapped file.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Large Files and Big Data finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by