%test script
%clears workspace
clearvars;
%generate a complex 3-D variable
D=rand(2,3,4)+j*rand(2,3,4);
%create basic ENVI header info about a Matlab variable
info=enviinfo(D);
%write the variable and the associated header info in a pair of binary/header ENVI files
enviwrite(D,info,'a.dat'); %implicit header file is "a.dat.hdr" (if not explicitly passed)
%read a complex n-D variable from "a.dat" and "a.dat.hdr" ENVI files
[D2,info2]=enviread('a.dat');
%some comparisons to validate consistency of our read/write procedures
isequal(D,D2)
isequal(info,info2)
%modify the header info (introducing offset in ENVI header)
info3=info2;
info3.header_offset=10000;
D3=D2; %same as D2
%writing the D3 (same as D2), but with 10000 offset
enviwrite(D3,info3,'a3.dat');
%read the offset variable (D3)
[D3a,info3a]=enviread('a3.dat');
%comparisons to validate read/write
isequal(D3,D3a)
isequal(info3,info3a)
|