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 167607

Submitted on 24 Nov 2012 by @bmtran

Correct

20Size
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                        access_mem_map_file_testsuite.m
.                                Shared                           zmap1s.dat
..                               access_mem_map_file.m
goal =
  2510330286
ans =
  2510330286
   516772220
  3017582989
  1262469879
ans =
  2411786675
ans =
  2510330286
           2
  3017582989
  1262469879