function DATA=heprev2mat(txt_root)
%
% Call DATA=heprev2mat(txt_root)
%
% txt_root  = Excel text file root (suffix='.txt') (blank to choose one);
%
%
% COPYRIGHT (c) 2008
% 
% Applied Research Laboratories, The University of Texas at Austin
% (ARL:UT)
% All rights reserved.
% 
% This material may be reproduced by or for the U.S. Government
% only. This notice must appear in all copies of this file and its
% derivatives. Further distribution outside the U.S. Government is
% prohibited without the explicit written authorization from the
% Director of the Environmental Sciences Laboratory, ARL:UT.
% 
% THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
% EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE
% IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
% PURPOSE, OR NONINFRINGEMENT.
% 
% IN NO EVENT WILL ARL:UT BE LIABLE FOR ANY DAMAGES WHATSOEVER ARISING
% OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN IF ARL:UT HAS
% BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
if nargin<1, txt_root=[]; end
%
DATA=[];
if isempty(txt_root),
    [txt_file,path_name]=uigetfile('*.txt', ...
		['Please Choose HEP Reverb Text File (Cancel to abort)']);
    if isempty(txt_file); return; end
    txt_root=txt_file(1:end-4);
end
txt_file=[txt_root,'.txt'];
if exist(txt_file)~=2, disp(['Text file ',txt_file,' not found.']); return; end
%
nfreq=8;
data=load([txt_root,'.txt']);
[ntime,ncol]=size(data);
nbuoy=(ncol-1)/nfreq;
if round(nbuoy)~=nbuoy, disp('Unexpected number of buoys: check nfreq assumed.'); return; end
% OUTPUTS
% DATA			= Structure containing data, dimensions, scales, and labels;
% DATA.data		= Data matrix;
% DATA.dims		= Array containing data matrix dimensions;
% DATA.scales	= Cell array containing axis values;
% DATA.labels	= Cell array containing axis labels in (1:ndim) and data label in (ndim+1);
% status	= 0 for success, negative for failure;
DATA.ndim=3;
DATA.labels={'Time - s','Buoy No.','Frequency - Hz'};
DATA.scales={data(:,1)', [1:nbuoy], [25,50,100,200,400,800,1600,3200]};
DATA.dims=[length(DATA.scales{1}), length(DATA.scales{2}), length(DATA.scales{3})];
DATA.data=NaN*ones(DATA.dims);
for jfreq=1:nfreq,
    jcol1=2 + (jfreq-1)*nbuoy;
    jcol2=jcol1 + nbuoy-1;
    DATA.data(:,:,jfreq)=data(:,jcol1:jcol2); 
end
DATA.dlab='Reverb Level - dB//uPa^2';
DATA.title=txt_root;
%
str=['save ',txt_root,' DATA']; disp(str); eval(str);
vdims=[2 1 3];
view5(DATA,vdims);
