Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 155309

Submitted on 29 Oct 2012 by Aurelien Queffurust

Correct

33Size
Leading solution size is 20.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
zmap1s=uint32(randi(2^32,1000,1));
% Write File to enable memory map load
fid = fopen('zmap1s.dat','w');
fwrite(fid, zmap1s, 'uint32');
fclose(fid);
dir
goal=zmap1s(1)
clear zmap1s
% Create the memmap variable
zmap1s = memmapfile('zmap1s.dat','Format', 'uint32','Writable',true);
zmap1s.data(1:4) % accessing the data
zmap1s.data(end)
y = access_mem_map_file(zmap1s);
zmap1s.data(1:4) % accessing the data
assert(isequal(y,goal));
assert(isequal(zmap1s.data(2),2));
+cody
.
..
Published
Shared
access_mem_map_file.m
access_mem_map_file_testsuite.m
zmap1s.dat
goal =
  1067853251
ans =
  1067853251
  1939773749
   978019141
  3455084653
ans =
  1247526902
zmap1s =
    Filename: '/users/msssystem16/zmap1s.dat'
    Writable: true
      Offset: 0
      Format: 'uint32'
      Repeat: Inf
        Data: 1000x1 uint32 array
y =
  1067853251
ans =
  1067853251
           2
   978019141
  3455084653