This solution is outdated. To rescore this solution, log in.
Test  Status  Code Input and Output 

1  Pass 
%%
m=ones(4,'uint16');
bmv = bitmask(m);
assert(isinteger(bmv),sprintf('NonInteger return'))
assert(isequal(bmv,[255 255]))

2  Pass 
%%
m=zeros(4,'uint16');
m(1)=1;
m(16)=1;
bmv = bitmask(m);
assert(isequal(bmv,[128 1]),[sprintf('Expected [128 1] saw: ') sprintf('%i ',bmv)])

3  Pass 
%%
m=zeros(3,'uint16');
m(8)=1;
m(9)=1;
bmv = bitmask(m);
assert(isequal(bmv,[1 128]))

4  Pass 
%%
%Duplicity test
m=randi(65535,[8 4],'uint16');
for i=1:12
m(randi(32))=0;
end
bmv = bitmask(m);
mb=m>0;
bmv_exp=[128 64 32 16 8 4 2 1]*mb;
assert(isequal(bmv,bmv_exp))

5  Pass 
%%
% Load aviris file Layer 1 ; 1.8MB mat file
tic % approx 2.5 sec to write and load
urlwrite('http://tinyurl.com/matlabavmofL001','aviris_moffett_L001.mat');
toc
load('aviris_moffett_L001.mat');
toc
% Array variable is L001
%Files also posted are L010,L023,L157, and L158 with same tinyurl format
% L010 and L023 have high contrast L157 and L158 are in atmospheric notch
bmv=bitmask(L001);
% L001 (1:8) [1271 1259 1271 0 0 0 0 0]
assert(isequal(bmv(1),224),sprintf('Expected 224 saw: %i',bmv(1)))
assert(isequal(bmv(181097),0),sprintf('Expected 0 saw: %i',bmv(181097)))
assert(isequal(bmv(90800),255),sprintf('Expected 255 saw: %i',bmv(90800)))
