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 149776

Submitted on 17 Oct 2012 by Vitaly Lavrukhin

Correct

20Size
This is the leading solution.
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 =
  4130877726
ans =
  4130877726
  3763485178
  2098646767
  1748380397
ans =
  1769335072
ans =
  4130877726
           2
  2098646767
  1748380397